For me, the code from SessionTest was not of any help :o((( This happened in my own case. getCurrentContext() returns null when running axis as a client. Have no idea why... maybe because I did not supply an wsdd client file ?!?!?
IN order to enable session tracking, I have done the following: My service (server) is scope="Application" (don't want a session scope). I have an entry method for my service, called "Login". When you connect from client to service by calling login method, the service gives you a Cookie. (Set Cookie:blah blah blah; /axis). You have to keep this cookie on client and all the calls that you will make to the server should contain the coockie. Here comes the bad part: On client, I create ca Session().createCall(). Set the call to Login method. set the call.setMantainSession( true ) (something like this) and call the login. Then, whatever call I am going to make, I am going to use the same Call object wich I have used for login. The call object keeps the cookie and sends it all the time you ask for a method. What I don't like is that I have to keep the same Call object, and this seems not to be normal. But if I try to create a new Call object, I don't know how to obtain the session id from the old one and how to set it on the now one??? Hope it helps, dovle > I worked myself through this code over there, but here is still a big > problem. Always, when I try to use the MessageContext.getCurrentContext() > method I get a NullPointerException. > I think there is something missing in my code, what I overread since now. > I read that I would have to include the SessionHandler on both sides > (client and server) inside the requestFlow. But: I actually dont use a wsdd > for my client. Do I have to? Everything I do is: > > Service service = new Service(); > Call call = (Call)service.createCall(); > service.setMaintainSession(true); > if(MessageContext.getCurrentContext() == null) > { > System.out.println("context is null"); > } > call.setTargetEndpointAddress(new java.net.URL(endpoint)); > QName operation = new QName(nameSpace, methodName); > call.setOperationName(operation); > Object returnval = call.invoke(new Object[]{args}); > if(MessageContext.getCurrentContext() == null) > { > System.out.println("context is null"); > } > > on both tests if the MessageContext is null, it is null. Ignoring the > MessageContext and the session, the webservice is running. What else do I > need? For example: How to deploy my client? Since now, I didnt find > something explaining this. > > thanks for help from Hamburg/Germany > > -----Ursprüngliche Nachricht----- > Von: Matthias Brunner [mailto:[EMAIL PROTECTED]] > Gesendet: Mittwoch, 4. Dezember 2002 22:42 > An: [EMAIL PROTECTED] > Betreff: Re: Howto enable sessions with axis > > > On Wednesday 04 December 2002 17:25, > > [EMAIL PROTECTED] wrote: > > I know this is not supposed to be a very hard question, but I'm > > searching for some sample-code or explanation how to enable > > session-handling in axis. I'm using a Tomcat 4.0.4 as Axis-server and > > a simple java-console-application as a client. > > So, what do I have to do to, for example, store authentication > > data inside a session? > > Have a look at the session test in the source distribution of axis.