• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sessions in Axis

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 http://www.asp.net toolkit for generating my .NET client.
Thank you.
Regards
Balaji
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
try
{
call = (Call)service.createCall();

// SET YOUR HEADER HERE.
call.addHeader(instanceOfSOAPHeaderElement);
}
catch(ServiceException se)
{
se.printStackTrace();
}
}

// 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: http://www.w3.org/TR/soap12-part1/ 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.

Cheers,

Brian Abbott
 
reply
    Bookmark Topic Watch Topic
  • New Topic