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 ro...@apache.org on 2007/07/17 18:58:55 UTC
svn commit: r556970 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/client/async/
jaxws/src/org/apache/axis2/jaxws/context/utils/
jaxws/src/org/apache/axis2/jaxws/core/controller/
jaxws/src/org/apache/axis2/jaxws/handler/ j...
Author: rott
Date: Tue Jul 17 09:58:50 2007
New Revision: 556970
URL: http://svn.apache.org/viewvc?view=rev&rev=556970
Log:
make sure attachment properties are accessible from handlers,
other necessary places
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/BaseMessageContext.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/JAXWSMessageReceiver.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java?view=diff&rev=556970&r1=556969&r2=556970
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java Tue Jul 17 09:58:50 2007
@@ -21,8 +21,10 @@
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.handler.AttachmentsAdapter;
import org.apache.axis2.jaxws.handler.HandlerChainProcessor;
import org.apache.axis2.jaxws.handler.HandlerInvokerUtils;
+import org.apache.axis2.jaxws.handler.TransportHeadersAdapter;
import org.apache.axis2.jaxws.spi.Constants;
import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigratorUtil;
import org.apache.commons.logging.Log;
@@ -205,6 +207,8 @@
// TODO: IMPORTANT: this is the right call here, but beware that the messagecontext may be turned into
// a fault context with a fault message. We need to check for this and, if necessary, make an exception and throw it.
// Invoke inbound handlers.
+ TransportHeadersAdapter.install(response);
+ AttachmentsAdapter.install(response);
HandlerInvokerUtils.invokeInboundHandlers(response.getMEPContext(),
response.getInvocationContext().getHandlers(),
HandlerChainProcessor.MEP.RESPONSE,
@@ -251,7 +255,10 @@
// it is possible the message could be null. For example, if we gave the proxy a bad endpoint address.
// If it is the case that the message is null, there's no sense running through the handlers.
if (faultMessageContext.getMessage() != null)
- // Invoke inbound handlers.
+ // Invoke inbound handlers.
+ // The adapters are intentionally NOT installed here. They cause unit test failures
+ // TransportHeadersAdapter.install(faultMessageContext);
+ // AttachmentsAdapter.install(faultMessageContext);
HandlerInvokerUtils.invokeInboundHandlers(faultMessageContext.getMEPContext(),
faultMessageContext.getInvocationContext()
.getHandlers(),
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java?view=diff&rev=556970&r1=556969&r2=556970
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java Tue Jul 17 09:58:50 2007
@@ -175,10 +175,6 @@
}
}
- soapMessageContext.put(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_CODE,
- axisMsgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));
- soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_CODE,
- Scope.APPLICATION);
}
public static void addWSDLProperties(MessageContext jaxwsMessageContext) {
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java?view=diff&rev=556970&r1=556969&r2=556970
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java Tue Jul 17 09:58:50 2007
@@ -22,8 +22,10 @@
import org.apache.axis2.jaxws.core.InvocationContext;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.core.util.MessageContextUtils;
+import org.apache.axis2.jaxws.handler.AttachmentsAdapter;
import org.apache.axis2.jaxws.handler.HandlerChainProcessor;
import org.apache.axis2.jaxws.handler.HandlerInvokerUtils;
+import org.apache.axis2.jaxws.handler.TransportHeadersAdapter;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.util.Constants;
import org.apache.commons.logging.Log;
@@ -124,6 +126,8 @@
response.setEndpointDescription(request.getEndpointDescription());
// Invoke inbound handlers.
+ TransportHeadersAdapter.install(response);
+ AttachmentsAdapter.install(response);
HandlerInvokerUtils.invokeInboundHandlers(response.getMEPContext(),
ic.getHandlers(),
HandlerChainProcessor.MEP.RESPONSE,
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/BaseMessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/BaseMessageContext.java?view=diff&rev=556970&r1=556969&r2=556970
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/BaseMessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/BaseMessageContext.java Tue Jul 17 09:58:50 2007
@@ -19,6 +19,8 @@
package org.apache.axis2.jaxws.handler;
import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.util.Collection;
import java.util.Map;
@@ -34,6 +36,7 @@
*
*/
public class BaseMessageContext implements javax.xml.ws.handler.MessageContext {
+ private static final Log log = LogFactory.getLog(BaseMessageContext.class);
protected MessageContext messageCtx;
@@ -82,7 +85,44 @@
* @see java.util.Map#get(java.lang.Object)
*/
public Object get(Object key) {
- return messageCtx.getMEPContext().get(key);
+ // There are some properties that, in some cases, should not span the message exchange;
+ // that is, they should come from only the current message context. For others properties,
+ // they should span the message exchange, meaning a property could be set on the request
+ // and it will also be available on the response. [JAXWS 2.0, Sec 9.4.1.1, pp. 110-113]
+ Object returnValue = null;
+ if (shouldPropertySpanMEP(key)) {
+ returnValue = messageCtx.getMEPContext().get(key);
+ } else {
+ returnValue = messageCtx.getProperty((String) key);
+ }
+
+ // For the HTTP_REQUEST_HEADERS and HTTP_RESPONSE_HEADERS, the CTS tests want a null returned
+ // if there are no headers. Since we always put an instance of TransportHeadersAdapter,
+ // which contains the headers, on the message context, return a null if it is empty.
+ if (returnValue != null && (returnValue instanceof TransportHeadersAdapter)) {
+ TransportHeadersAdapter adapter = (TransportHeadersAdapter) returnValue;
+ if (adapter.isEmpty()) {
+ return null;
+ }
+ }
+ return returnValue;
+ }
+
+ private boolean shouldPropertySpanMEP(Object key) {
+ boolean shouldSpan = true;
+ String keyString = (String) key;
+
+ // The CTS tests require that HTTP_REQUEST_HEADERS span the request and response contexts
+ // on the service-provider, but do NOT span the request and response context on the
+ // service-requester. So, for an INBOUND flow, do not allow HTTP_REQUEST_HEADERS to
+ // span the request and response contexts. The result is that the service-requester
+ // inbound handler will not see the request headers while processing a response.
+ Boolean outbound = (Boolean) messageCtx.getMEPContext().get(MESSAGE_OUTBOUND_PROPERTY);
+ if (outbound != null && !outbound)
+ if (javax.xml.ws.handler.MessageContext.HTTP_REQUEST_HEADERS.equals(keyString)) {
+ shouldSpan = false;
+ }
+ return shouldSpan;
}
/* (non-Javadoc)
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/JAXWSMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/JAXWSMessageReceiver.java?view=diff&rev=556970&r1=556969&r2=556970
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/JAXWSMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/JAXWSMessageReceiver.java Tue Jul 17 09:58:50 2007
@@ -32,6 +32,8 @@
import org.apache.axis2.jaxws.core.InvocationContextImpl;
import org.apache.axis2.jaxws.core.MEPContext;
import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.handler.AttachmentsAdapter;
+import org.apache.axis2.jaxws.handler.TransportHeadersAdapter;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.message.util.MessageUtils;
import org.apache.axis2.jaxws.util.Constants;
@@ -96,7 +98,10 @@
MessageContext requestMsgCtx = new MessageContext(axisRequestMsgCtx);
requestMsgCtx.setMEPContext(new MEPContext(requestMsgCtx));
-
+ // The adapters need to be installed on the new request Message Context
+ AttachmentsAdapter.install(requestMsgCtx);
+ TransportHeadersAdapter.install(requestMsgCtx);
+
Binding binding = (Binding)axisRequestMsgCtx.getProperty(PARAM_BINDING);
InvocationContext ic = InvocationContextFactory.createInvocationContext(binding);
ic.setRequestMessageContext(requestMsgCtx);
@@ -133,10 +138,9 @@
faultToReturn = responseMsgCtx.getCausedByException();
else {
faultToReturn = new AxisFault("An error was detected during JAXWS processing",
- axisResponseMsgCtx);
-
+ axisResponseMsgCtx);
}
- } else {
+ } else {
//This assumes that we are on the ultimate execution thread
ThreadContextMigratorUtil.performMigrationToContext(
Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, axisResponseMsgCtx);
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java?view=diff&rev=556970&r1=556969&r2=556970
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java Tue Jul 17 09:58:50 2007
@@ -36,6 +36,7 @@
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.util.CallbackReceiver;
import org.apache.axis2.util.Utils;
import org.apache.axis2.wsdl.WSDLConstants;
@@ -371,6 +372,13 @@
AxisEngine.send(msgContext);
responseMessageContext.setDoingREST(msgContext.isDoingREST());
+
+ // Copy RESPONSE properties which the transport set onto the request message context when it processed
+ // the incoming response recieved in reply to an outgoing request.
+ responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
+ msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
+ responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
+ msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));
responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
.getProperty(MessageContext.TRANSPORT_IN));
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?view=diff&rev=556970&r1=556969&r2=556970
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Tue Jul 17 09:58:50 2007
@@ -101,8 +101,11 @@
*/
protected void obtainHTTPHeaderInformation(HttpMethodBase method,
MessageContext msgContext) throws AxisFault {
+ // Set RESPONSE properties onto the REQUEST message context. They will need to be copied off the request context onto
+ // the response context elsewhere, for example in the OutInOperationClient.
Map transportHeaders = new CommonsTransportHeaders(method.getResponseHeaders());
msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, transportHeaders);
+ msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, new Integer(method.getStatusCode()));
Header header = method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
if (header != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org