Andrew,

Thank you for responding to my e-mail however I still cannot get sessions to work on my Axis2 setup.

I added the code you provided to the method like this:

   public int TestSessionMethod() {
SessionContext sessionContext = MessageContext.getCurrentMessageContext().getSessionContext(); int myCounter = 0; myCounter = 1 + Integer.parseInt((String)sessionContext.getProperty("thisCounter").toString()); sessionContext.setProperty("thisCounter", myCounter ); return myCounter ;
   }


When I call this method from my Mozilla web browser:

http://localhost:8080/axis2/services/MyService/TestSessionMethod

The method is working correctly and I get returned a soap message containing an incrementing result. I've confirmed the session working (versus application) by opening IE and calling the same method. The results from IE are as expected : 1, 2, 3 ... etc.

I cannot get this method working from an RPC client though. Here is my code from my jsp client:

<%
   returnValue  = "-99";

       try {

           MyServiceStub stub = new MyServiceStub();
           stub._getServiceClient().getOptions().setManageSession(true);
MyServiceStub.TestSessionMethod myServicerequest = new MyServiceStub.TestSessionMethod(); TestSessionMethodResponse myServiceResponse = stub.TestSessionMethod(myServicerequest);
           returnValue = String.valueOf(myServiceResponse.get_return());
       }
       catch (Exception e) {
           returnValue = "Exception: " + e;
} out.println(returnValue); %>

The result is always :  1, 1, 1, ... etc.


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.

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.

What else am I missing to get sessions working for Axis2?

Thank you in advance,
James





Andrew Martin wrote:
Store session information like this:
MessageContext.getCurrentMessageContext().getSessionContext().setProperty(key,
val)
Retrieve it like this:
MessageContext.getCurrentMessageContext().getSessionContext().getProperty(key)

Andrew

James Neff wrote:
in my services.xml I have the attribute scope="TransportSession".

In my client I have this:

myServiceStub stub = new myServiceStub();
myServiceStub.MyMethod myServiceRequest = new myServiceStub .MyMethod();
myServiceRequest .setParameter(parameterValue);
stub._getServiceClient().getOptions().setManageSession(true);

But the session is not keeping.

It looks like the myService is getting instantiated for each call, and
not being held in a session.

What am I doing wrong?

Thanks in advance,
Jim


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to