Question

I access a SOAP service using adb-stubs created by axis2 and I should get sessionId and cookies from response, then send with another request...

I need get this parameters which you may see at the picture

http://www.imageup.ru/img36/1635686/skrinshot-2014-01-23-104646.png

MessageContext msgCtx = serviceStub._getServiceClient().getLastOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
msgCtx.getProperty(HTTPConstants.HTTP_HEADERS);
SOAPHeader  soapHeader = msgCtx.getEnvelope().getHeader();

I tried these, but I could get result :( Also I set manageSession parameters to true.

When I debuged request and response I got following log:

2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "HTTP/1.1 200 OK[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Cache-Control: private, max-age=0[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Content-Length: 505[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Content-Type: text/xml; charset=utf-8[\r][\n]"
2014/01/23 12:35:55:372 ALMT [DEBUG] header - << "Server: Microsoft-IIS/7.5[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "X-AspNet-Version: 2.0.50727[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "Set-Cookie: ASP.NET_SessionId=agj1njnpvoerup45tqnmsz45; path=/; HttpOnly[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "X-Powered-By: ASP.NET[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "Date: Thu, 23 Jan 2014 06:35:59 GMT[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] header - << "[\r][\n]"
2014/01/23 12:35:55:382 ALMT [DEBUG] CookieSpec - Unrecognized cookie attribute: name=HttpOnly, value=null
2014/01/23 12:35:55:382 ALMT [DEBUG] HttpMethodBase - Cookie accepted: "$Version=0; ASP.NET_SessionId=agj1njnpvoerup45tqnmsz45; $Path=/"

Please, help me.

Was it helpful?

Solution

After much anguish, I found the answer ... I retrieve cookies from axis2 stub response with following code:


        CommonsTransportHeaders cth = (CommonsTransportHeaders) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
        String cookie = (String) cth.get(WSConstants.SET_COOKIE);

I hope this will help others :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top