wood burning stoves 2.0*
The moose likes Web Services and the fly likes HttpSessionScope is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "HttpSessionScope is not working" Watch "HttpSessionScope is not working" New topic
Author

HttpSessionScope is not working

Danny Llv
Greenhorn

Joined: Jun 22, 2013
Posts: 2
Hello ranchers!

I'm a newbie to WebServices in Java.
I'm trying to use HttpSessionScope in my project, but for some reason the session is not remembered.

I created the following code to test what's going wrong.
The idea is to
- call for "init" WS method to initialize rand variable with a random int - "session id" & print the id number in GlassFish Server output window in NetBeans.
- afterward, call for getIdmethod. This will print the id number .
The value should stay the same.

The problem is that when calling getIdmethod i get 0 as value.
It looks like the value that has been initialized is lost.

Why does it happen?
What I'm doing wrong? Been trying to figure out for hours

Thank you in advance, Danny



Danny Llv
Greenhorn

Joined: Jun 22, 2013
Posts: 2
I had to import javax.xml.ws.BindingProvider; and add ( (BindingProvider) welcomeSOAPProxy ).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); in the client code.
Here is the condensed code:

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
Using HTTP sessions for WS is generally considered bad design. The usual approach for authentication would be to for the initial response to send back a cryptologically secure authentication token which is then passed along with all subsequent requests.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSessionScope is not working