• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to implement Stateful webservices?

 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • 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
  • 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: 3654
38
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
She still doesn't approve of my superhero lifestyle. Or this shameless plug:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic