Richard,

yeah, I had some basic questions about sessions a couple weeks ago, and 
they got answered pretty well.  You can check the list archives for the 
thread "how to implement sessions, persistent objects, etc. ?".  The way 
you're implementing sessions, I'd guess the thing you're missing is a line 
in the deploy.wsdd file that Stan Jordan pointed out.  Here's the relevant 
section:

  <service name="StatefulService" provider="java:RPC">
   <parameter name="className" value="StatefulService"/>
   <parameter name="allowedMethods" value="*"/>
   <parameter name="scope" value="session"/>
  </service>

note the parameter "scope", which sets this service to have "session scope" 
(i.e. it remembers session information across requests).

As Steve Loughran pointed out, since this method relies on cookies, it ties 
your service to HTTP and to clients that understand cookies (not part of 
the SOAP spec).  It looks like the only alternative to using cookies is to 
write all the session maintenance code yourself and store session info in a 
database or application-scoped objects.  That's what I'm looking into, and 
if I get anything working I'll post an example.

Andrew

At 01:58 PM 4/30/2002 +0100, you wrote:
>I'm running AXIS in Orion Application Server 1.5.4 on Win XP with J2SDK1.4.0
>
>All the small examples I've tried are working perflectly and I'm really
>impressed with AXIS so far!
>
>I've come across a problem getting a very simple example working to
>demonstrate session maintenance (following on from the example on
>javaworld.com).
>
>Here's my client code:
>
>     HelloServerService service = new
>javaworld.axis.proxy.HelloServerServiceLocator();
>     HelloServer port = service.getHelloServer();
>     ((HelloServerSoapBindingStub) port).setMaintainSession (true); // keep
>session open
>     port.setOwner("Test"); // set variable that should be session maintained
>
>     // make the call
>     String ret = port.sayHelloTo(args[0]);
>     System.out.println(ret);
>
>Here's the Web Service:
>
>     String owner = new String();
>
>     public void setOwner(String name) {
>         System.out.println("setOwner(String name)");
>         owner = name;
>     }
>
>     public String sayHelloTo(String name) {
>         System.out.println("sayHelloTo(String name) - owner=" + owner);
>
>         if (owner != null && owner.equals(name))
>             return "Hello " + name + ", You are my owner";
>         else
>             return "Hello " + name + ", How are you doing?";
>     }
>
>I'm running this simply as a .jws file on my app server, then generating the
>proxies with WSDL2Java for the client.
>
>However when I run it with a parameter of "Test" the debug shows it has
>setOwner but sayHelloTo returns '....How are you doing?'
>
>Is there anything else I need to do?
>Has anyone got any better examples (I've looked at WidgetPrice and
>AddressFinder and they seem to be doing the same thing).
>
>Thanks,
>
>Richard Taylor
>New Scientist Developer



Reply via email to