title: getting http session cookies in spring-ws soap web service client
body: <p>I have a SOAP web service client written with Spring-WS. In response to a logon request, the web service I connect to returns a session cookie in the HTTP response header with a token in it. Each subsequent call to the service requires that cookie with the token. How can I get the session cookie from the response and then add it to the HTTP header on subsequent calls to the service?</p>
  
  <p>To summarize what I'm asking, how do you extract and inject cookies with Spring-WS.</p>
  
  <p>Here is a snippet of code similar to what I am using to call into the web service:</p>
  
  <pre><code>    MySessionLogon api = new MySessionLogon();
      api.setUsername(username);
      api.setPassword(password);
  
      MySessionLogonResponse response = (MySessionLogonResponse) getWebServiceTemplate()
              .marshalSendAndReceive(
                      "http://myserver/soapservice.asmx",
                      api,
                      new SoapActionCallback("http://www.myserver.com/MySession_Logon"));
  
      return response;
  </code></pre>
  
  <p>I have searched the internet and read a lot of things that seem close to what I need, but I haven't seen a good way to get the value of the cookies I need to use. Any help would be appreciated, thanks in advance.</p>