Andrew Martin wrote:
...
It looks like you're creating a new client each time you call the
service, so each call would be in a separate session. What happens if
you invoke the service multiple times with the same client object?
How do I do that from a JSP page? Is there an example somewhere I can
follow?
I added to my Web Service class a constructor:
public MyService() {
System.out.println("MyService.constructing!");
int testCounter = 0;
SessionContext sessionContext =
MessageContext.getCurrentMessageContext().getSessionContext();
sessionContext.setProperty("thisCounter", testCounter);
}
And when I go to /logs/catalina.out I see :
MyService.constructing!
for as many times as I call the method from my RPC client.
That's what I would expect. If you store session information in the
SessionContext, then that wouldn't matter.
I thought thats what I was doing here with SessionContext. Did I do it
wrong?
Also, the session does work when I use "application" for the scope. But
when I try "transportsession" or "soapsession" in the "scope" attribute
of services.xml it always acts like "request" scope.
If you use "application", then you wouldn't get a separate counter for
each session. Every user would be incrementing the same counter. If
that's what you want, then do that. If you really want to store
separate variables for each session, then your server's already doing
the right thing with "transportsession", according to your web browser
test. You just need to change your client.
Yes, I want a separate session for each user. I said the thing about
"application" because I just wanted to make sure the thing was working
at least at some level. Now it seems, as you've pointed out, my client
is getting created anew each time I click the button my JSP web page.
How can I call the same session from my JSP page?
Thanks again in advance,
James