• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extract cookies from SOAP response using AXIS2  RSS feed

 
Riju Mahna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I am consuming a third party webservice using AXIS2 stub. The primary method which I use works FINE and has below signature:



The webservice is supposed to return a String (token) in the response headers as cookie :- WSToke
But I cannot find ANY method to extract the headers and cookies from the response. In fact there is no HTTPResponse object to fetch the cookies !!
I have tried this code:



But it returns a null value as there is no such property in the context. The MessageContext has below properties:

transport.http.statusCode
CHARACTER_SET_ENCODING
TRANSPORT_HEADERS
org.apache.axiom.om.util.DetachableInputStream
messageType
ContentType
TRANSPORT_IN

How can I get the cookie called 'WSToken' from the response using the stub ?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't use cookies with WS. Why isn't all data returned in a response data object?
 
Riju Mahna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a third party web service and I have to only consume it in our code.
Apparently, it works easily in .NET code. But I am unable to find in it java using Axis2
 
g tsuji
Ranch Hand
Posts: 697
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can get the MessageContext properly, it should open up the logic to get the transport headers and in particular the Set-Cookie setting you might be looking for. You may try this.

Edit: correct a typo on org.apache.axis2.transport.http.HTTPConstants instead MessageContext.
 
Riju Mahna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the TRANSPORT_HEADERS and got all the header. The Set-Cookie header is also included in it.

But the strange situation is that the DESIRED cookies are not being fetched. They are, however, visible when the webservice is consumed using a .net application.
From my java application, I only get some irrelevant cookies.

Is there some other way to fetch the cookies, other than the TRANSPORT_HEADERS ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!