• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extract cookies from SOAP response using AXIS2

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic