Neil,
Snowed in, huh?
The short answer is "Yes".
In the code I wrote (and found to work) I call it before the first call.
For example:
HelloServiceLocator serviceLocator = new HelloServiceLocator();
stubs.Hello service = serviceLocator.getGreeter( new
java.net.URL("http://localhost:8080/axis/services/Greeter"));
((org.apache.axis.client.Stub)service).setMaintainSession(true);
System.out.println(service.say("Dude_1"));
System.out.println(service.say("Dude_2"));
(The code above used generated stubs for a service registered as 'Greeter'
based on a class called Hello.)
If you use TCPMonitor to watch the SOAP messages being passed back and
forth, you'll see that in response to the first call, the service returns a
session ID as one of the header fields. This session ID gets passed back by
the client on every subsequent call.
Be aware that the use of 'stateful services' appears to be somewhat
non-standard (for reasons that I do not completely grasp) -- probably
because recognition of the session relies on the use of header fields;
perhaps because there is no means of specifying scope using WSDL -- or
things of that nature.
Of course, depending on what you're doing, statefulness of one's service
might be unavoidable. Then again, it should be quite doable to maintain a
concept of state (using some clever pattern), even w/o relying on JAX-RPC to
maintain session scope!
Don't take my opinions/impressions as 'gospel' -- I'm no SOAP guru -- not
yet!
-----Original Message-----
From: Hainer Neil [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 10:56 AM
To: [EMAIL PROTECTED]
Subject: Re: Code for Session Scope
Timothy,
Should I be calling setMaintainSession before the first method invocation on
the
service instance. Right now I have called it between the first and second
method calls and axis behaves as if I'm not using session scope. I would
have
tried this before asking, but I'm snowed in at home and my code is at work.
TIA,
Neil
"Almeida, Timothy" wrote:
> There's no need to call setMaintainSession() more than once to keep the
> session alive, provided you're using the same service instance on
successive
> calls. (I've tried this, so I know it works.)
>
> > -----Original Message-----
> > From: Hainer Neil [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, February 25, 2003 4:10 PM
> > To: AXIS User
> > Subject: Code for Session Scope
> >
> > Hi,
> >
> > I'm confused about the following:
> >
> > I have a service which has it's scope set to "session". Do I still
code:
> >
> > service object.setMaintainSession(true);
> >
> > between method invocations to keep the original session alive?
> >
> > Thanks,
> >
> > Neil
> >
> > Neil Hainer
> > << OLE Object: Picture (Metafile) >>
> > 8283 Greensboro Drive
> > McLean, Virginia 22102-3838
> > 703-902-6828
> > [EMAIL PROTECTED]
> >