Axis2 has cookie handling logic in its HttpSender and AbstractHttpSender
classes which seems to duplicate (or at least not be synchronized with)
similar logic in the commons-http client code...
If I dig into the serviceContext object and set the Axis2 property
called HTTPConstants.COOKIE_STRING to null, that solves the problem.
msgCtx.getServiceContext().setProperty(HTTPConstants.COOKIE_STRING,
null);
________________________________
From: Merritt, Norris
Sent: Friday, September 28, 2007 12:56 PM
To: [email protected]
Subject: [Axis2]: Duplicate Cookie header in requests from Axis2 client
My Axis2 client is somehow sending TWO cookie headers on each POST
request, with slightly different formatting but the same JSESSIONID:
Cookie: JSESSIONID=69C868C8CC13EA14A5E8846FC87E2EB8
Cookie: $Version=0; JSESSIONID=69C868C8CC13EA14A5E8846FC87E2EB8;
$Path=/myservice
This is a problem for me because occasionally my server invalidates the
JSESSIONID I am using if too much time elapses between requests and
fails the operation due to an invalid JSESSIONID. In this case I need
to resend the failed request without any Cookie header, whereupon the
server will create a new session and issue a new JSESSIONID.
I succeeded in getting rid of ONE of the Cookie headers by doing this:
HttpClient httpClient = (HttpClient)
msgCtx.getConfigurationContext()
.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
httpClient.getState().clearCookies();
This gets rid of the Cookie header with the $Version and $Path, but not
the other one. So when I retry the request, I am still sending a Cookie
header with an invalid JSESSIONID. Does anyone know where is this
duplicate cookie header coming from, and how I can get rid of it?