If anybody is interested, attached is a workaround to this problem.
// Standard binding (though with some explicit casts) - note the maintain session
Service1Locator service1Locator=new Service1Locator();
Service1SoapBindingStub service=(Service1SoapBindingStub)service1Locator.getService1();
service1Locator.setMaintainSession(true);
service.foo();
// get the cookie
Call authCall = service1Locator.getCall();
org.apache.axis.MessageContext msgContext = authCall.getMessageContext();
String cookie = msgContext.getStrProp(HTTPConstants.HEADER_COOKIE);
// Standard binding
Service2Locator service2Locator=new Service2Locator();
Service2SoapBindingStub
service2=(Service2SoapBindingStub)service2Locator.getbusinessUnitService();
service2Locator.setMaintainSession(true);
// And now - SET THE COOKIE
service2._setProperty(HTTPConstants.HEADER_COOKIE,cookie);
service2.bar();
-----Original Message-----
From: Omri Spector
Sent: Thursday, November 04, 2004 11:57 AM
To: [EMAIL PROTECTED]
Subject: Problem: Sharing session between two services
Hi all,
I am writing a client application using Axis to access web services. The server
publishes an "Authentication" service and a bunch of "Functional" services.
I am expected to login using the first and then call the other services passing the
same session cookie.
A .Net client worked fine, as I had the ability to share the "CookieManager". In axis,
though, I cant seem to make it work:
// Bind to authentication service
AuthenticationServiceService authLocator=new AuthenticationServiceServiceLocator();
AuthenticationService auth=authLocator.getauthService();
((AuthServiceSoapBindingStub)auth).setMaintainSession(true); // maintain session
auth.login("user","password");
// bind to a functional service
FunctionalServiceService serviceLocator=new FunctionalServiceServiceLocator();
FunctionalService service=authLocator.getfunctionalService();
((FunctionalServiceSoapBindingStub)service).setMaintainSession(true); // maintain
session - but it is not the right session
service.doSomething(); // Will throw 403
How can I make both stubs share the same session / cookies?
This is especially frustrating since the server is Axis - and I cant write an Axis
client...
Omri Spector