0

I am calling another service using spring boot. When I have my configuration as follows, it does not add the jsessionid(cookie) returned from the service i am calling.

public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
    RestTemplate rt = restTemplateBuilder
        .rootUri(uri)
        .basicAuthentication(
                 username
                ,password)
        .additionalInterceptors(new RestTemplateInterceptor(stuff, stuff))
        .build();
    rt.setRequestFactory(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));

    return rt;          
}

when I call with this configuraiton it does add the jsessionid(cookie) from the service I call.

public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
    RestTemplate rt = restTemplateBuilder
        .rootUri(uri)
        .basicAuthentication(
                 username
                ,password)
        .build();
    
    return rt;          
}

My question is how can I get the BuffereingClientHttpRequestFactory to add the jsessionid(cookie) form previous calls to the service?

Thanks in advance

Brian
  • 556
  • 6
  • 26

1 Answers1

0

this seems to have solved my problem (look at HttpComponentsClientHttpRequestFactory)

public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
RestTemplate rt = restTemplateBuilder
    .rootUri(uri)
    .basicAuthentication(
             username
            ,password)
    .additionalInterceptors(new RestTemplateInterceptor(stuff, stuff))
    .build();
rt.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));

return rt;          

}

Brian
  • 556
  • 6
  • 26