• 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

How to implement Stateful webservices?

 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I was reading through an article on www.java.net on how to implement the state across multiple conversations with webservices.

My initial understanding was ws-addressing combined with ws-reliablemessaging provides a very good support of session management. Please correct me If I'm wrong here.

and certain annotations like @Stateful can be used along with StatefulWebServiceManager also support session management.

Now out of these various methods, the one presented in java.net seem to be very simple. But can some one guide me, which of the above options are actually correct and usable and if yes, any justification of each.

Also, apart from the above, are there any other ways of managing sessions. Also, I see that Ivan's notes which talks about the session management in chapter 4 (JAX-WS) resembles the one posted in the java.net article. Is this the widely adopted process ?
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Managing state with a web service means that some data that should have been stored in the requests is stored on the web service side. Commonly, but not always, statefulness is used due to a design flaw.
Stateful example:
When client A sends its first request to a stateful web service, the state is established and for every subsequent request from client A, the web service retains the state associated with client A.
Compare this to patients going to see the doctor. Statelessness is a patient going to see the doctor at a big hospital; the patient cannot choose which doctor to see, but sees a random doctor each time.
Statefulness is a patient going to see a specific doctor - the patient returns to the same clinic each visit and sees the same doctor.

I cannot see how WS-Addressing and WS-ReliableMessaging would be able to facilitate stateful web services.

Also, as far as I know, @Stateful is used to annotate a stateful session bean and in section 3.2.4 of the EJB 3.1 specification it says:

Stateless session beans and Singleton session beans may have web service clients.


Thus you cannot expose a stateful session beans as a web service.
Best wishes!
 
Bartender
Posts: 3908
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivan Krizsan wrote:
Also, as far as I know, @Stateful is used to annotate a stateful session bean and in section 3.2.4 of the EJB 3.1 specification it says:

Stateless session beans and Singleton session beans may have web service clients.


Thus you cannot expose a stateful session beans as a web service.



I guess, above was mentioned [probably] another @Stateful annotation:
http://www.docjar.com/docs/api/com/sun/xml/internal/ws/developer/Stateful.html
But it's not part of JAX-WS, and is not portable (and not tested on the exam )
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Mikalai Zaikin wrote:
I guess, above was mentioned [probably] another @Stateful annotation:
http://www.docjar.com/docs/api/com/sun/xml/internal/ws/developer/Stateful.html
But it's not part of JAX-WS, and is not portable (and not tested on the exam )


Ah, thanks for pointing this out!
Best wishes!
 
Greenhorn
Posts: 10
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kumar Raja wrote:
Also, apart from the above, are there any other ways of managing sessions.



You could extract the HTTPSESSION in your webservice.



When you first call this method you'll receive a response with a "Set-Cookie" parameter in its header.
Copy this value, paste it in the "Cookie" header in your next request, and tataaaa ... counter is 2
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic