jQuery in Action, 2nd edition*
The moose likes Web Services and the fly likes Cookie in SOAP Handler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Cookie in SOAP Handler" Watch "Cookie in SOAP Handler" New topic
Author

Cookie in SOAP Handler

Daisy Log
Greenhorn

Joined: Feb 04, 2011
Posts: 4
Hi,

I have a program in which I need to remember the session Id for the requests that pass through the same SOAP Handler. If I use static variable it gets altered to the the last modification. So I decided on cookies.

But if I add a cookie to the response message to the servlet I am not getting the cookie in the following reuest message.

Can anyone suggest me an idea?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
You should not be using either cookies or HTTP sessions with web services. Return a token ID as part of the response; then the client can send that along with the next request.


Ping & DNS - my free Android networking tools app
Daisy Log
Greenhorn

Joined: Feb 04, 2011
Posts: 4
Actually I cannot make any changes in the client part as it belongs to someone else. I need to create the handler with a point that I dont know any details in the web application.

I cant use a static variable as for multiple instances it takes the last value. So am thinking of some way.

I also need to know how to display an error web page directly from the SOAPHandler???
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Note that JAX-WS web service clients must be configured to maintain session information (such as cookies), using the javax.xml.ws.session.maintain property.
Other web service stacks may have similar mechanisms.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Cookie in SOAP Handler