You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Stefan Kühnel <St...@gmx.net> on 2008/08/28 21:33:41 UTC
Re: [Axis2] Handling sessions across two web services
Hello *,
I think the following patch against the current SVN head of Axis2 should fix the problem.
Any comments on the approach?
Thanks,
Stefan
Index: modules/transports/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
===================================================================
--- modules/transports/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (revision 689928)
+++ modules/transports/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (working copy)
@@ -418,6 +418,21 @@
StringBuffer buffer = new StringBuffer();
buffer.append(cookieString);
httpMethod.setRequestHeader(HTTPConstants.HEADER_COOKIE, buffer.toString());
+
+ // Set the cookie in the ServiceContext in case the server returns
+ // no Set-Cookie/Set-Cookie2 header for an already existing session
+ // and this is the first call in the session using this ServiceContext.
+ //
+ // If we don't do this, we will get a WebServiceException ("NoMaintainSessionProperty")
+ // in org.apache.axis2.jaxws.BindingProvider.setupSessionContext();
+ //
+ // If the server returns a cookie, the value we set here will be overriden
+ // in the method obtainHTTPHeaderInformation() above.
+ //
+ // A setup where the described situation can happen is
+ // when the user manually manages the session cookie independent
+ // from the lifetime of the ServiceContext/Proxy.
+ msgContext.getServiceContext().setProperty(HTTPConstants.COOKIE_STRING, buffer.toString());
}
}
-------- Original-Nachricht --------
> Datum: Mon, 18 Aug 2008 20:08:01 +0200
> Von: "Stefan K�hnel" <St...@gmx.net>
> An: axis-dev@ws.apache.org
> Betreff: Handling sessions across two web services
> Hello *,
>
> we're getting the error "Error: Maintain Session is enabled but none of
> the
> session properties (Cookies, Over-written URL) are returned." when we're
> trying to use the same HTTP session over two different web service client
> proxies. Both proxies point to web services on the same webserver under
> different paths (a la http://example.org/service1 and
> http://example.org/service2). The Set-Cookie2 from the first service has a
> path of "/", so the cookie is valid for the second web service as well.
>
> The problem is that even though we copy the cookie from the first proxy to
> the second proxy via the requestContext, Axis thinks there is no valid
> session in the second proxy since the second web service returns no cookie
> via Set-Cookie.
>
> The problem is, if I analyze this correctly, that the second proxy uses
> its
> own ServiceContext, that is not shared with the ServiceContext of the
> first
> proxy. The value we store in the requestContext is only used in the
> request, but not copied into the ServiceContext. Therefore on return of
> the
> call from the server, when Axis tries to set up the requestContext for the
> next call, this exception is raised, because it doesn't find the cookie in
> the ServiceContext. This set-up of the next� request happens in
> org.apache.axis2.jaxws.BindingProvider.setupSessionContext(), where the
> exception is raised.
>
> The question now is, do you know of a workaround? Preferably one using
> only
> JAX-WS features, so that we're not getting an explicit dependency on Axis.
>
> In abstract terms, we would need the ability to
> * create the first proxy
> * make the first call
> * extract the session state (aka "sessionValue" in terms of the method
> setupSessionContext) from the proxy
> * persist the session state
>
> When making the call to the second web service, we want to
> * load the session state from our persistent store
> * create the second proxy
> * set the session state for this proxy
> * make the second call
>
> Thanks,
> Stefan
--
GMX Kostenlose Spiele: Einfach online spielen und Spa� haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196