• 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

Stateful Web Service

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JAX-WS has got @Stateful annotation using which a Web Service can be made stateful.In JEE putting @Stateful annotation makes a bean Stateful Session bean.

So does this means that a Web Service Endpoint can be Servlet based or EJB Based (Stateless or Stateful) ? In JAX-RPC we could not have Stateful Session bean as Web Service ?
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aha! When I saw JAX-WS RI extension for stateful web services, I knew this would happen. The Stateful annotation for web services is com.sun.xml.ws.developer.Stateful and the Stateful annotation for ejb is javax.ejb.Stateful - two different things.

A few things must be noted about stateful web services:
1. This is a vendor extension and not a standard specification, which means your code gets tied to the implementation and will not survive any server migrations
2. Different vendors use different ways to provide stateful web services. For example, IBM uses WS-Addressing and WS-Resource but Sun uses RI extension. I still think it's best to avoid stateful services
3. I believe Sun should avoid asking questions about things that are proprietary

Now, if you still want to do stateful web services, you need to download and use appropriate version of JAX-WS RI that has this extension. In your code, you must use @com.sun.xml.ws.developer.Stateful AND @Addressing annotations in addition to the usual @Webservice annotation.

Since we have established that the Stateful annotation doesn't make your class a stateful ejb, we must worry about the state management of the class. The container provided state management mechanism for a stateful web service is StatefulWebServiceManager class. Read more about this at here and here.
 
Sim Kim
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chintan !
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sim Kim:
JAX-WS has got @Stateful annotation using which a Web Service can be made stateful.



Have you actually checked the JAX-WS specification? Stateful isn't anywhere in JAX-WS 2.1 MR2. As far as I can tell Stateful has been relegated to "plumbing" in WSIT/Metro to deal with some of the less standardized WS-* coordination and orchestration protocols that .NET uses.

See A question about JAX-WS Stateful Web Service.
 
Sim Kim
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peer !

That was nice explanation.
 
pie. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic