3 Replies Latest reply on Feb 5, 2007 4:18 AM by jova73

    Web services and stateful session

    jova73

      Hi,
      I'm working with JBoss 4.0.5 and the embedded JBoss Web Service support.
      I have to expose as web services some functionalities of an existing J2EE application with stateful session management, i.e. I've a javax.ejb.Handle object which references my session and this handle must be passed to every method of the business logic EJBs.
      Questions:
      - how can I expose this Handle object to a web service client?
      javax.ejb.Handle is not supported by JAX-RPC so I was considering serializing this object (e.g. base64 encoding). Is there any better method?

      - I serialized my handle object to a file and it's less then 400 bytes: is that the average size of a serialized JBoss javax.ejb.Handle?

      - is there any standard, implemented by JBoss 4.0.5, for a web service conversation?
      I'd like to have my web service client making the following calls:
      perform login
      request one or more service (each one once or more times)
      perform logout

      Maybe I'm wrong but I think that my model doesn't fit in BPEL (I can't know in advance which and how many services a client will call between login() and logout())... Any suggestion?

      Thanks in advance,
      Andrea

        • 1. Re: Web services and stateful session
          dwin

          hey Andrea

          as of JAX-WS 2.0, there is no supprt for stateful sessions. In JAX-WS 2.1, there is a concept of stateful webservices which is done through ws-addressing.

          I would not recommend serializing the Handle object, if need be make a representation (or key) of the handle and pass that to the WS client. Each time that key is returned, you can used that to look up the handle.

          In fact, I don't even think its possible.


          You can mimick a session by defining the lifecycle of a session (starts at login, ends at logout). Of course, you would have to persist/maintain state on the server side.

          • 2. Re: Web services and stateful session
            heiko.braun

            Dwin is right. WS-Addressing is the right way to build conversational web services. Take a look at the user guide and the corresponding samples. It contains an example for a staful service. It's already supported for quiet some time now:
            http://labs.jboss.com/portal/jbossws/user-guide/en/html/wsaddressing.html

            IMO passing the serialized handle around is not a good idea. I could picture a SLSB facade instead that keeps a UUID->Handle registry and delegates to the SFSB beans behind the scenes. You could hand out the UUID using WS-Adressing and internally rely on the ejb handle. You could even offer a simple API for clients to resign from their sessions.

            • 3. Re: Web services and stateful session
              jova73

              THANK YOU VERY MUCH, Dwin and Heiko!!!
              I will follow your suggestions and check WS-Adressing.

              Bye,
              Andrea