views:

49

answers:

1

Is it possible in jax-ws to have a webmethod that creates a new object (of a service class) and returns a reference to it to the client caller (for the client, it's a remote reference) so that the client and this new service object maintain a session? (Therefore each client is served by a different instance). Schematically:

client                                   server                    o:Session
--------                                 --------                  ----------
    s = server.access() ------------------>         
                                            o = new Session()
                                            return o
                                         <---


    o.doSomething() ---------------------------------------------->
                                                                     make it  
                                                                   <---

    o.doMore()  --------------------------------------------------> 
                                                                    make it  
                                                                   <---
+1  A: 

Did you check Stateful Web Service with JAX-WS RI? The programming model has been reported to be dead simple. Have a look at it.

Pascal Thivent
Thanks, I'll take a look now
cibercitizen1
@Pascal: Hi: I found this page https://jax-ws-commons.dev.java.net/http-session-scope/that seems to solve the problem with an annotation.What do you think?
cibercitizen1
@cibercitizen1 Well, it's an extension to JAX-WS (i.e. not portable). But if it suits your needs **and** if using an extension is not a concern for you then why not.
Pascal Thivent
@Pascal: Thanks, I do appreciate your help. Well the problem is that I'm trying to do with WS things that are straightforward with RMI. For example the one in my question. RMI references for remote objects are clear and portable and interchangeable among RMI java programas. But it seems to me that WS are not for this. Am I right?
cibercitizen1
@cibercitizen1 Yes you're right. Web services are stateless by nature and attempts to make them stateful are IMO kinda hacks, they are not really designed for this. And even when using stateful services, you're still dealing with messages, not objects. RMI (or a stateful EJB) would be indeed more appropriate for such thingss.
Pascal Thivent