Spring WebServiceTemplate add value to Cookie header

The solution we’ve found :

JAXBElement<ESignatureResponse> response = (JAXBElement<ESignatureResponse>) getWebServiceTemplate()
                .marshalSendAndReceive(objectFactory.createESignature(request), new WebServiceMessageCallback() {
                    @Override
                    public void doWithMessage(WebServiceMessage webServiceMessage) throws IOException, TransformerException {
                        HttpClient httpClient = ((HttpComponentsMessageSender) getWebServiceTemplate().getMessageSenders()[0]).getHttpClient();
                        BasicClientCookie iamCookie = new BasicClientCookie(iamConfigurationProperties.getCookieName(), iamCookieValue);
                        iamCookie.setDomain(iamConfigurationProperties.getCookieDomain());
                        iamCookie.setPath(iamConfigurationProperties.getCookiePath());
                        ((DefaultHttpClient) httpClient).getCookieStore().addCookie(iamCookie);
                    }
                });

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top