You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Brian Manley <ma...@telcordia.com> on 2004/05/24 22:51:40 UTC
Getting Set-Cookie header
All,
I know this has been asked a million times, but I haven't been able
to find a suitable solution in the list archives. So, I'll ask again...
I have two services running in a cluster of web servers. I have a
load balancer sitting in front of this cluster. All service requests
go through this load balancer.
My client uses WSDL2Java generated Service/Stub classes.
When I invoke the first service, the load balancer inserts a Set-Cookie
header in the HTTP response. I need to extract this header value and use
it in a Cookie to be sent with all subsequent service requests on
other services. This will ensure that my request goes back to the
proper server in the cluster.
I cannot, for the life of me, get this value out of my stub!
I can set a cookie without any problem. It's getting the initial
one that has me stumped. I've also tried getting HEADER_COOKIE,
HEADER_COOKIE2, and HEADER_SET_COOKIE2. Nothing seems to work.
It's critical that I get this working. It can be done quite easily
using .NET WSE, and I have clients working with that. I'd like
to be able to have clients using Axis too! :)
Any help would be greatly appreciated!
-- Brian
SOAPSecurityServiceLocator securityLocator = new SOAPSecurityServiceLocator();
securityLocator.setMaintainSession(true);
SOAPSiteServiceLocator siteLocator = new SOAPSiteServiceLocator();
siteLocator.setMaintainSession(true);
SOAPSecurity securityService = securityLocator.getSOAPSecurity();
String securityToken = securityService.login("xxxx","xxxx","xxxx","xxxx");
// Get the value of the Set-Cookie header?
// This always returns null!
String jSessionId = (String)((javax.xml.rpc.Stub)securityService)._getProperty(HTTPConstants.HEADER_SET_COOKIE);
SOAPSite siteService = siteLocator.getSOAPSite();
// Set the cookie value
// Always fails since jSessionId is null!
((javax.xml.rpc.Stub)siteService)._setProperty(HTTPConstants.HEADER_COOKIE, jSessionId);