Meaningless Drivel is fun!*
The moose likes Web Services and the fly likes A question about Jax-Ws Stateful Web Srevice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "A question about Jax-Ws Stateful Web Srevice" Watch "A question about Jax-Ws Stateful Web Srevice" New topic
Author

A question about Jax-Ws Stateful Web Srevice

Thomas Chang
Ranch Hand

Joined: May 13, 2008
Posts: 61
I use the Jaxs-WS to build a stateful web service. The service looks as follwo:


And the client looks as follow:


But as I run the client, I got exception as follow:
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2921
    
    5

Is a universal XML name. The phrasing may suggest that the information in the <service> element of the WSDL that you are referencing is in some way incorrect.
Thomas Chang
Ranch Hand

Joined: May 13, 2008
Posts: 61
Sorry, the exception I posted above is wrong. The correct exception I got is as follow:
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2921
    
    5
Summary:
I seems to me that while the Stateful annotation was in EA2, it didn't make the final release (possibly because of the lack of standardization that would enable a client to configure itself correctly - based only on the WSDL). You probably now need Metro to get this to work.

I presume that you are referring to Kohsuke Kawaguchi's Blog: Stateful web service with JAX-WS RI 2.1 EA2 (2006-Oct-24) and Java TM API for XML Web Services
(JAX-WS) Stateful Web Service with JAX-WS RI


Yet there is nothing in the final specification JAX-WS 2.1 (maintenance release 2, 2007-May-08) about the Stateful annotation.

The entire point of the blog is the technique that follows that doesn't use the Stateful annotation in a "stateless" web service. In that example a javax.xml.ws.wsaddressing.W3CEndpointReference is returned which is a {http://www.w3.org/2005/08/addressing}Address element that contains the address to an entirely new web service endpoint reference (EPR) that represents that particular bank account instance. The following client code makes this clear as you have to connect the port of the bank account separately. So you are dealing with 2 clients and WSDLs:
  • client to obtain the temporary instance Bank Account EPR URL
  • client to access the BankAccount at that EPR URL



  • The EPRs are "exported" by a subclass of com.sun.xml.ws.developer.StatefulWebServiceManager. Notice the package name? It's in a Sun package, so it is Sun's implementation and isn't an official part of JAX-WS. This was part of Glassfish and there have been problems with it.
    https://glassfish.dev.java.net/issues/show_bug.cgi?id=2082
    Despite the fact that the issue was closed people continued to have problems with it. Currently there is no trace of StatefulWebServiceManager on the Glassfish Fisheye subversion repository. It seems that this functionality has now moved to WSIT/Metro (WSIT focuses on interoperability with .NET web services).

    Note that in general stateful web services are a bad idea anyway because stateful web services do not scale well. Furthermore web service and their clients deal with messages - not objects. If multiple requests need to refer to some common set of data (that may be stored in a back-end database) then an explicit correlation identifier (in a header or inside the document) is needed - {http://jax-ws.dev.java.net/xml/ns/}objectId is ultimately that correlation ID. For example, in Pattern 3: Request/reply operations with polling a correlation ID is used in a subsequent request to refer to the context of the previous request.

    The approach outlined in the blog may seem more "object-oriented" and convenient - that does not imply that is appropriate for interoperable SOAP message based web services. Time and time again people have found out that objects and SOAP web services actually don't mix and that many "convenient developer features for developing web services" ultimately cause more problems than they solve.

    IEEE Internet Computing July/August 2008; Vol. 12, No. 4: Convenience Over Correctness (PDF)
    [ November 17, 2008: Message edited by: Peer Reynders ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: A question about Jax-Ws Stateful Web Srevice
     
    Similar Threads
    JAX-WS Authentication problem -javax.xml.ws.WebServiceException Response: '401: Unauthorized'
    WSDL access error
    Attempt to retrieve Sharepoint WSDL fails with “Server redirected too many times”
    problem with jax-ws trying to overide default callback endpoint address
    JAX-WS Service invocation fails after service discovery with JAXR