axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Kühnel" <>
Subject JAX-WS client: Using one HTTP session to call different webservices
Date Thu, 14 Aug 2008 19:43:45 GMT

this might not be the right list since it is probably mostly a JAX-WS 
client programming question, but since I have tracked the problem to Axis2, 
I hope you can help me anyway.

We have developed a client for some webservices using JAX-WS under 
WebSphere. The web services we have to call are designed in such a way, 
that service2.methodB() must be called in the same HTTP session as 

The question now is:
* How can one transfer the session info from one service proxy (service1) 
to another one (service2), so that it is sucessfully used by 
service2.methodB() even if this method returns no more session information 
via Set-Cookie2?

The way we tried is by setting the property 
to true for the requestContext of both web service proxies (service1 and 
service2). We also extracted the cookie returned by service1.methodA() and 
set it in the requestContext for service2.methodB().

The call to the server returns a valid SOAP response (the cookie is in the 
HTTP request for service2.methodB(), the session on the server is found, 
processing there is successful).

But during the processing of the response on the client, Axis returns an 
exception with the message "Error: Maintain Session is enabled but none of 
the session properties (Cookies, Over-written URL) are returned." This 
exception comes from 

If I've analysed this correctly, the reason for the exception is that the 
ServiceContext properties don't contain a cookie. This even though we have 
set the cookie returned by service1.methodA() to the requestContext of 
service2 before the call to service2.methodB().

My assumption now is that the cookie is set only in the ServiceContext 
properties, if a HTTP response really contains a "Set-Cookie2: xxx", but 
not if we set the cookie to the requestContext before the call.

As an alternative solution, we tried to set 
to false for service2, and still set the cookie value to the requestContext 
of service2, but then the cookie is not even sent to the server.

So I'm looking for ways to achieve a successful connection to 
service2.methodB() using the session from service1.methodA() even in this 
particular scenario.

Thanks for any help,

PS: The relvant code from BindingProvider is below (found at

     * Check for maintain session state enablement either in the
     * MessageContext.isMaintainSession() or in the ServiceContext 
     * @param mc
     * @param ic
protected void checkMaintainSessionState(MessageContext mc, 
InvocationContext ic) {
        Map<String, Object> properties = 
boolean bValue = false;

if (properties != null
            && properties
.containsKey( {
            bValue = (Boolean) properties
if (mc.isMaintainSession() || bValue == true) {

    * Ensure that the next request context contains the session value 
    * from previous request
protected void setupSessionContext(Map<String, Object> properties) {
        String sessionKey = null;
        Object sessionValue = null;

if (properties == null) {

if (properties.containsKey(HTTPConstants.HEADER_LOCATION)) {
            sessionKey = HTTPConstants.HEADER_LOCATION;
            sessionValue = properties.get(sessionKey);
if (sessionValue != null && !"".equals(sessionValue)) {
        } else if (properties.containsKey(HTTPConstants.HEADER_COOKIE)) {
            sessionKey = HTTPConstants.HEADER_COOKIE;
            sessionValue = properties.get(sessionKey);
if (sessionValue != null && !"".equals(sessionValue)) {
        } else if (properties.containsKey(HTTPConstants.HEADER_COOKIE2)) {
            sessionKey = HTTPConstants.HEADER_COOKIE2;
            sessionValue = properties.get(sessionKey);
if (sessionValue != null && !"".equals(sessionValue)) {
        } else {
throw ExceptionFactory

if (sessionValue == null) {
throw ExceptionFactory.makeWebServiceException(
Messages.getMessage("NullValueForMaintainSessionProperty", sessionKey));
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!

View raw message