• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

HttpSessionScope is not working

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic