public static void setRequestCookieTest(HelloWS port)
{
String sessionId = "blah:blah:1234";
System.out.println("Session id: " + sessionId);
final HttpCookie jSessionId = new HttpCookie("JSESSIONID=" + sessionId);
System.out.println("Cookie name: " + jSessionId.getName());
System.out.println("JSessionId: " + jSessionId.toString());
Map<String, List<String>> headers = (Map<String, List<String>>) ((BindingProvider) port)
.getRequestContext().get( MessageContext.HTTP_RESPONSE_HEADERS);
if (null == headers) {
System.out.println("Headers was null");
headers = Collections.singletonMap("Cookie", Collections
.singletonList(jSessionId.toString()));
((BindingProvider) port).getRequestContext().put(
MessageContext.HTTP_REQUEST_HEADERS, headers);
} else {
System.out.println("Headers was not null");
List<String> cookies = headers.get("Cookie");
if (null == cookies) {
System.out.println("Cookies was null");
cookies = new ArrayList<String>();
headers.put("Cookie", cookies);
} else {
System.out.println("Cookies was not null");
cookies.add(jSessionId.toString());
}
}
port.hello("Kyle");
}