[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kandula-dev
Subject:    Re: Cookie getting overwritten when client connects to multiple servers.
From:       santhoshs123 <santhoshs123 () gmail ! com>
Date:       2013-03-26 6:36:30
Message-ID: 1364279790325-112131.post () n7 ! nabble ! com
[Download RAW message or body]

Hi Folks,

I figured out the solution for this. Thank you all for having a look at this
post. Below is the solution

Axis provides a way to avoid overwriting of cookies from different servers
by capturing the cookie which is having the specified name, the cookie name
can be specified by setting ServiceContext properties with key
"Constants.CUSTOM_COOKIE_ID". If HTTPResponse header of any API response
contains the cookie specified then Axis captures that cookie and sets it on
to ServiceContext properties with key "HTTPConstants.COOKIE_STRING". If
client sets this captured cookie on to ServiceClient.Options with same key
then Axis adds this cookie to HTTPRequest header of each API called using
the corresponding ServiceClient. By doing this, Client can make sure that
the cookies with the same name but from different services won't be
overwritten in client by Axis as they will be saved in their corresponding
ServiceClients.

Below are the steps to follow:
1. Specify name of the cookie to be captured by Axis. This property can be
specified when we initialize the stub. If the property
"Constants.CUSTOM_COOKIE_ID" is set then Axis tries to find and capture the
specified cookie from HTTP Respose header of each API call and if it finds,
Axis sets that cookie (ex: "cookieName=value") into ServiceContext property
"HTTPConstants.COOKIE_STRING".
         
stub._getServiceClient().getServiceContext().setProperty(Constants.CUSTOM_COOKIE_ID,
"XXXSESSIONID");
2. Get the captured cookie from ServiceContext properties and set it on to
stub.ServiceClient.Options so that future API calls using this stub(to
particular service) will be attached with this captured cookie. This can be
done after the API call for which the server is supposed to set cookie.
         String sessionCookie = (String)
stub._getServiceClient().getServiceContext().getProperty(HTTPConstants.COOKIE_STRING);
  options = stub._getServiceClient().getOptions();
         options.setProperty(HTTPConstants.COOKIE_STRING, sessionCookie);
         stub._getServiceClient().setOptions(options);

Thanks again to all of you.

If anybody needs any help in the future, please ask your questions here I
will try to assist you.

-Santhosh



--
View this message in context: \
http://axis.8716.n7.nabble.com/Cookie-getting-overwritten-when-client-connects-to-multiple-servers-tp111918p112131.html
 Sent from the Axis Java - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic