Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 64528 invoked from network); 7 Oct 2008 20:34:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Oct 2008 20:34:34 -0000 Received: (qmail 63595 invoked by uid 500); 7 Oct 2008 20:34:28 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 63466 invoked by uid 500); 7 Oct 2008 20:34:27 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 63443 invoked by uid 500); 7 Oct 2008 20:34:26 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 63435 invoked by uid 99); 7 Oct 2008 20:34:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Oct 2008 13:34:26 -0700 X-ASF-Spam-Status: No, hits=-1999.9 required=10.0 tests=ALL_TRUSTED,DNS_FROM_SECURITYSAGE X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Oct 2008 20:33:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9FE29238889D; Tue, 7 Oct 2008 13:34:04 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r702617 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client: dispatch/BaseDispatch.java proxy/JAXWSProxyHandler.java Date: Tue, 07 Oct 2008 20:34:04 -0000 To: axis2-cvs@ws.apache.org From: rott@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081007203404.9FE29238889D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rott Date: Tue Oct 7 13:34:04 2008 New Revision: 702617 URL: http://svn.apache.org/viewvc?rev=702617&view=rev Log: Allow client applications to share session cookies among BindingProvider and Dispatch instances Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java?rev=702617&r1=702616&r2=702617&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java Tue Oct 7 13:34:04 2008 @@ -38,6 +38,7 @@ import org.apache.axis2.jaxws.spi.Constants; import org.apache.axis2.jaxws.spi.ServiceDelegate; import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigratorUtil; +import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -141,6 +142,25 @@ initMessageContext(obj, requestMsgCtx); + /* + * if SESSION_MAINTAIN_PROPERTY is true, and the client app has explicitly set a HEADER_COOKIE on the request context, assume the client + * app is expecting the HEADER_COOKIE to be the session id. If we were establishing a new session, no cookie would be sent, and the + * server would reply with a "Set-Cookie" header, which is copied as a "Cookie"-keyed property to the service context during response. + * In this case, if we succeed in using an existing server session, no "Set-Cookie" header will be returned, and therefore no + * "Cookie"-keyed property would be set on the service context. So, let's copy our request context HEADER_COOKIE key to the service + * context now to prevent the "no cookie" exception in BindingProvider.setupSessionContext. It is possible the server does not support + * sessions, in which case no error occurs, but the client app would assume it is participating in a session. + */ + if ((requestContext.containsKey(BindingProvider.SESSION_MAINTAIN_PROPERTY)) && ((Boolean)requestContext.get(BindingProvider.SESSION_MAINTAIN_PROPERTY))) { + if ((requestContext.containsKey(HTTPConstants.HEADER_COOKIE)) && (requestContext.get(HTTPConstants.HEADER_COOKIE) != null)) { + invocationContext.getServiceClient().getServiceContext().setProperty(HTTPConstants.HEADER_COOKIE, requestContext.get(HTTPConstants.HEADER_COOKIE)); + if (log.isDebugEnabled()) { + log.debug("Client-app defined Cookie property (assume to be session cookie) on request context copied to service context." + + " Caution: server may or may not support sessions, but client app will not be informed when not supported."); + } + } + } + // Migrate the properties from the client request context bag to // the request MessageContext. ApplicationContextMigratorUtil.performMigrationToMessageContext( Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?rev=702617&r1=702616&r2=702617&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Tue Oct 7 13:34:04 2008 @@ -39,6 +39,7 @@ import org.apache.axis2.jaxws.spi.Constants; import org.apache.axis2.jaxws.spi.ServiceDelegate; import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigratorUtil; +import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -203,6 +204,25 @@ requestIC.setRequestMessageContext(request); requestIC.setServiceClient(serviceDelegate.getServiceClient(endpointDesc.getPortQName())); + /* + * if SESSION_MAINTAIN_PROPERTY is true, and the client app has explicitly set a HEADER_COOKIE on the request context, assume the client + * app is expecting the HEADER_COOKIE to be the session id. If we were establishing a new session, no cookie would be sent, and the + * server would reply with a "Set-Cookie" header, which is copied as a "Cookie"-keyed property to the service context during response. + * In this case, if we succeed in using an existing server session, no "Set-Cookie" header will be returned, and therefore no + * "Cookie"-keyed property would be set on the service context. So, let's copy our request context HEADER_COOKIE key to the service + * context now to prevent the "no cookie" exception in BindingProvider.setupSessionContext. It is possible the server does not support + * sessions, in which case no error occurs, but the client app would assume it is participating in a session. + */ + if ((requestContext.containsKey(BindingProvider.SESSION_MAINTAIN_PROPERTY)) && ((Boolean)requestContext.get(BindingProvider.SESSION_MAINTAIN_PROPERTY))) { + if ((requestContext.containsKey(HTTPConstants.HEADER_COOKIE)) && (requestContext.get(HTTPConstants.HEADER_COOKIE) != null)) { + requestIC.getServiceClient().getServiceContext().setProperty(HTTPConstants.HEADER_COOKIE, requestContext.get(HTTPConstants.HEADER_COOKIE)); + if (log.isDebugEnabled()) { + log.debug("Client-app defined Cookie property (assume to be session cookie) on request context copied to service context." + + " Caution: server may or may not support sessions, but client app will not be informed when not supported."); + } + } + } + // Migrate the properties from the client request context bag to // the request MessageContext. ApplicationContextMigratorUtil.performMigrationToMessageContext(