File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Sessions in Axis Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Sessions in Axis" Watch "Sessions in Axis" New topic

Sessions in Axis

Cory Wilkerson
Ranch Hand

Joined: Aug 14, 2001
Posts: 84
I have both java and .net clients using a web service I've built -- both clients are generating source code from the service's wsdl description. It seems to me as if subsequent client requests aren't maintaining state and I'm wondering if there's something I can congfiure server side to force state maintenance.
Anyone, anyone?
Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
Stateful web services are a bad, bad, bad idea. Maintaining cookies or session id's is totally outside of the SOAP specification -- it's not guaranteed, so you can't be assured it will happen.
Web services should always be stateless. If you need to store client-specific state, store it in a database, and pass the key with each Web Services call as a parameter.

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
Hi Cory,
I too had a java and .NET clients, recently my .NET clients(C#)is generating some errors which i'm trying to solve.
May I know what software you are using for creating .NET clients,any online resources,books you used.
I'm using toolkit for generating my .NET client.
Thank you.

Spritle Software Blogs
Brian Abbott

Joined: Sep 10, 2004
Posts: 1
I totally disagree with Kyle that the idea of passing session information in webservices somehow violates design ideas or negates the benefits of Web Services. Web Services is ultimately a mechanism for software component interaction. Theres no reason against or shortfall that you will encounter with using session information in Web Services.

The best way to pass session information is to include a session id in the SOAP Header. In AXIS, heres how you can do this:

class SOAPInvocationHandler implements InvocationHandler
String endpoint;
Service service;
Call call;

public SOAPInvocationHandler(String _endpoint)
endpoint = _endpoint;
service = new Service();
call = (Call)service.createCall();

catch(ServiceException se)

// your invoke method
public Object invoke(Object proxy, Method method, Object[] args)

In fact, the SOAP Standard supports this. For more information, the W3C recommendation can be accessed here: Section 5.2.1 covers custom header elements. Basically what they are saying is that while not every SOAP Processing engine must understand your unique element, no processor should crash on it.

This code also demonstrates creating an object proxy which can be useful on client-side programming.


Brian Abbott
I agree. Here's the link:
subject: Sessions in Axis
It's not a secret anymore!