WSO2Con 2013 CFP Banner

Session Management in Axis2 : Enabling Sessions on Client Side

Date: Tue, 5th Dec, 2006
Level:
Reads: 7580
Discuss this article on Stack Overflow
Deepal Jayasingha

WSO2 Inc.

Session management is very useful feature when it comes to enterprise level applications. However, few years ago there was not a single notion on session management in Web services . Now the situation is different. There is a trend towards managing sessions in Web services as it is not that easy to implement complex scenarios without the support of session management. Therefore Apache Axis2 has an inbuilt support for session management for both client side and server side. Not only this, it also has different levels of session scopes as well.

It's common knowledge that if we want to participate in an existing session, then we need to send some ID back to the server. In Axis2, if we want to be in the same SOAP session, then we need to send the Axis2 specific SOAP header parameter called "ServiceGroupID" back to the server. Similarly, if we want to be in the same transport session then we need to send the HTTP cookie back to the server. As a client it is a bit difficult to do all those manually. To solve this problem Axis2 client side has a very interesting flag.

If we want to interact with the server in a session-full manner, then we can turn the flag on, which will enable Axis2 to automatically send the required IDs back.

To turn the flag on, please add the following line(s) to your client code:

ServiceClient client = new ServiceClient();
client.getOptions().setManageSession(true);

Applies To:

Apache Axis2/Java 1.0 or above
anilchukkapalli's picture

Session Management in Axis2

Hi, Do I have to call setManageSession() on my client side proxy/stub for my webservice or is there any other mechanism of attaching this client to my web service proxy. What i can see is a separate ServiceClient object and you are calling setManageSession() on the object but i don't see how this object is associated with web service proxy/stub. My web service is a .NET web service and my client is an Axis2 client.
gs_ravishankar.hotmail.com's picture

session management in axis2 with .NET webservice

Hi Anil, is your problem resolved? because right now i have a similar problem the service which we are consuming is .NET service. it has two services first login service and then the service which will allow us update the data. my problem is when a user logs into my application and invokes this service and after that he does not do any activity for an hour or so then this user again invokes the service then session is getting expired. i have used options.setSessionManagement(true) in my stubs but still it is not working. my client is java. please let me know if there are any hints. Thank you in advance