cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r449679 [1/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/interceptor/ api/src/main/java/org/apache/cxf/message/ api/src/main/java/org/apache/cxf/phase/ api/src/main/java/org/apache/cxf/transport/ rt/core/src/main/java/org/a...
Date Mon, 25 Sep 2006 13:26:05 GMT
Author: eglynn
Date: Mon Sep 25 06:26:03 2006
New Revision: 449679

URL: http://svn.apache.org/viewvc?view=rev&rev=449679
Log:
Decoupled response support with system test

Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/GreeterImpl.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/HeaderVerifier.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPVerifier.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/VerificationCache.java   (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainSetupInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java
    incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
    incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java
    incubator/cxf/trunk/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/common/ClientServerSetupBase.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/common/TestServerBase.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/InterceptorChain.java Mon Sep 25 06:26:03 2006
@@ -42,6 +42,8 @@
     
     void resume();
     
+    void reset();
+    
     ListIterator<Interceptor<? extends Message>> getIterator();
 
     Interceptor getFaultInterceptor();

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java Mon Sep 25 06:26:03 2006
@@ -31,15 +31,11 @@
     
     String TRANSPORT = "org.apache.cxf.transport";    
     String REQUESTOR_ROLE = "org.apache.cxf.client";
-    String ONEWAY_MESSAGE = "org.apache.cxf.transport.isOneWayMessage";
 
     String INBOUND_MESSAGE = "org.apache.cxf.message.inbound";
     String INVOCATION_OBJECTS = "org.apache.cxf.invocation.objects";
     
     String MIME_HEADERS = "org.apache.cxf.mime.headers";
-
-    String CORRELATION_OUT = "org.apache.cxf.correlation.out";
-    String CORRELATION_IN = "org.apache.cxf.correlation.in";
     
     String PROTOCOL_HEADERS = Message.class.getName() + ".PROTOCOL_HEADERS";
     String RESPONSE_CODE = Message.class.getName() + ".RESPONSE_CODE";

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java Mon Sep 25 06:26:03 2006
@@ -58,7 +58,7 @@
     private final Map<String, List<Interceptor>> nameMap = new HashMap<String, List<Interceptor>>();
 
     private State state;
-    private ListIterator<Interceptor<? extends Message>> iterator;
+    private PhaseInterceptorIterator iterator;
     private Message pausedMessage;
     private Interceptor faultInterceptor;
     
@@ -151,6 +151,13 @@
         return state == State.COMPLETE;
     }
     
+    public void reset() {
+        if (state == State.COMPLETE) {
+            state = State.EXECUTING;
+            iterator.reset();
+        }
+    }
+    
     @SuppressWarnings("unchecked")
     private void unwind(Message message) {
         while (iterator.hasPrevious()) {
@@ -308,7 +315,15 @@
         public void set(Interceptor o) {
             throw new UnsupportedOperationException();
         }
-        
+
+        protected void reset() {
+            phases = interceptors.values().iterator();
+            if (phases.hasNext()) {
+                currentPhase = phases.next();
+                currentPhaseIterator = currentPhase.iterator();
+                last = null;
+            }
+        }
     }
 
     public Interceptor getFaultInterceptor() {

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/transport/Destination.java Mon Sep 25 06:26:03 2006
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 
-import javax.wsdl.WSDLException;
 
 import org.apache.cxf.message.Message;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
@@ -53,7 +52,7 @@
     Conduit getBackChannel(Message inMessage,
                            Message partialResponse,
                            EndpointReferenceType address)
-        throws WSDLException, IOException;
+        throws IOException;
 
     /**
      * Shutdown the Destination, i.e. stop accepting incoming messages.

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Mon Sep 25 06:26:03 2006
@@ -89,7 +89,6 @@
         }    
         //setup the message context
         setContext(requestContext, message);
-        //setMethod(ctx, message);
         setParameters(params, message);
         Exchange exchange = new ExchangeImpl();
         if (null != requestContext) {
@@ -178,20 +177,18 @@
     }
 
     private Message waitResponse(Exchange exchange) {
-        Message inMsg = exchange.getInMessage();
-        if (inMsg == null) {
+        while (exchange.getInMessage() == null) {
             try {
                 exchange.wait();
             } catch (InterruptedException e) {
                 //TODO - timeout
             }
-            inMsg = exchange.getInMessage();
         }
-        if (inMsg.getContent(Exception.class) != null) {
+        if (isException(exchange)) {
             //TODO - exceptions 
-            throw new RuntimeException(inMsg.getContent(Exception.class));
+            throw new RuntimeException(exchange.getInMessage().getContent(Exception.class));
         }
-        return inMsg;
+        return exchange.getInMessage();
     }
 
     private void setParameters(Object[] params, Message message) {
@@ -205,6 +202,7 @@
     public void onMessage(Message message) {
         message = endpoint.getBinding().createMessage(message);
         message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
+        message.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
         PhaseManager pm = bus.getExtension(PhaseManager.class);
         PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getInPhases());
         message.setInterceptorChain(chain);
@@ -235,8 +233,10 @@
             chain.doIntercept(message);
         } finally {
             synchronized (message.getExchange()) {
-                message.getExchange().setInMessage(message);
-                message.getExchange().notifyAll();
+                if (!isPartialResponse(message)) {
+                    message.getExchange().setInMessage(message);
+                    message.getExchange().notifyAll();
+                }
             }
         }
     }
@@ -260,8 +260,23 @@
         return initedConduit;
     }
     
+    private boolean isPartialResponse(Message in) {
+        //Message in = exchange.getInMessage();
+        boolean partial = in.getContent(List.class) == null
+                          && in.getContent(Exception.class) == null;
+        //if (partial) {
+            //exchange.setInMessage(null);
+        //}
+        return partial;
+    }
+
+    private boolean isException(Exchange exchange) {
+        return exchange.getInMessage().getContent(Exception.class) != null;
+    }
+    
     protected void setOutMessageProperties(Message message, BindingOperationInfo boi) {
         message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
+        message.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
         message.put(BindingMessageInfo.class, boi.getInput());
         message.put(MessageInfo.class, boi.getOperationInfo().getInput());
     }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareOutInterceptor.java Mon Sep 25 06:26:03 2006
@@ -50,8 +50,14 @@
 
         int countParts = 0;
         List<MessagePartInfo> parts = null;
+
         if (!isRequestor(message)) {
-            parts = operation.getOutput().getMessageInfo().getMessageParts();
+            if (operation.getOutput() != null) {
+                parts = operation.getOutput().getMessageInfo().getMessageParts();
+            } else {
+                // partial response to oneway
+                return;
+            }
         } else {
             parts = operation.getInput().getMessageInfo().getMessageParts();
         }
@@ -59,18 +65,20 @@
 
         if (countParts > 0) {
             List<?> objs = message.getContent(List.class);
-            Object[] args = objs.toArray();
-            Object[] els = parts.toArray();
+            if (objs != null) {
+                Object[] args = objs.toArray();
+                Object[] els = parts.toArray();
                         
-            for (int idx = 0; idx < countParts; idx++) {
-                Object arg = args[idx];
-                MessagePartInfo part = (MessagePartInfo)els[idx];
-                if (part.isInSoapHeader()) {
-                    //this part should be in header, should donot write to soap body
-                    continue;
+                for (int idx = 0; idx < countParts; idx++) {
+                    Object arg = args[idx];
+                    MessagePartInfo part = (MessagePartInfo)els[idx];
+                    if (part.isInSoapHeader()) {
+                        //this part should be in header, should donot write to soap body
+                        continue;
+                    }
+                    QName elName = ServiceModelUtil.getPartName(part);
+                    dataWriter.write(arg, elName, message);
                 }
-                QName elName = ServiceModelUtil.getPartName(part);
-                dataWriter.write(arg, elName, message);
             }
         }
     }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/MessageSenderInterceptor.java Mon Sep 25 06:26:03 2006
@@ -23,6 +23,7 @@
 import java.util.ResourceBundle;
 
 import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -40,10 +41,15 @@
     }
 
     public void handleMessage(Message message) {
-        Conduit conduit = message.getConduit();
-        if (conduit == null) {
-            conduit = message.getExchange().getConduit();
-        }
+        Exchange exchange = message.getExchange();
+        Conduit conduit =
+            message.getConduit() != null
+            ? message.getConduit()
+            : exchange.getConduit() != null
+              ? exchange.getConduit()
+              : exchange.getOutMessage() != null
+                ? OutgoingChainInterceptor.getBackChannelConduit(exchange)
+                : null;
 
         try {
             conduit.send(message);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java Mon Sep 25 06:26:03 2006
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.interceptor;
 
+import java.io.IOException;
+
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -26,6 +28,8 @@
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessageInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
 
 public class OutgoingChainInterceptor extends AbstractPhaseInterceptor<Message> {
 
@@ -39,6 +43,7 @@
         Message out = ex.getOutMessage();
         
         if (out != null) {
+            getBackChannelConduit(ex);
             BindingOperationInfo bin = ex.get(BindingOperationInfo.class);
             if (bin != null) {
                 out.put(MessageInfo.class, bin.getOperationInfo().getOutput());
@@ -46,5 +51,23 @@
             }
             out.getInterceptorChain().doIntercept(out);
         }
+    }
+    
+    protected static Conduit getBackChannelConduit(Exchange ex) {
+        Conduit conduit = null;
+        if (ex.getOutMessage().getConduit() == null
+            && ex.getConduit() == null
+            && ex.getDestination() != null) {
+            try {
+                EndpointReferenceType target =
+                    ex.get(EndpointReferenceType.class);
+                conduit = ex.getDestination().getBackChannel(ex.getInMessage(), null, target);
+                ex.setConduit(conduit);
+            } catch (IOException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+        return conduit;
     }
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainSetupInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainSetupInterceptor.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainSetupInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainSetupInterceptor.java Mon Sep 25 06:26:03 2006
@@ -19,10 +19,6 @@
 
 package org.apache.cxf.interceptor;
 
-import java.io.IOException;
-
-import javax.wsdl.WSDLException;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
@@ -49,17 +45,7 @@
             return;
         }
         
-        Bus bus = ex.get(Bus.class);
-        PhaseManager pm = bus.getExtension(PhaseManager.class);
-        PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases());
-        
         Endpoint ep = ex.get(Endpoint.class);
-        chain.add(ep.getOutInterceptors());
-        chain.add(ep.getService().getOutInterceptors());
-        chain.add(bus.getOutInterceptors());        
-        if (ep.getBinding() != null) {
-            chain.add(ep.getBinding().getOutInterceptors());
-        }
         
         Message outMessage = message.getExchange().getOutMessage();
         if (outMessage == null) {
@@ -73,19 +59,22 @@
             ex.setFaultMessage(faultMessage);
         }
         
-        if (outMessage.getConduit() == null
-            && ex.getConduit() == null
-            && ex.getDestination() != null) {
-            try {
-                ex.setConduit(ex.getDestination().getBackChannel(message, null, null));
-            } catch (WSDLException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            } catch (IOException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
+        outMessage.setInterceptorChain(getOutInterceptorChain(ex));
+    }
+    
+    public static InterceptorChain getOutInterceptorChain(Exchange ex) {
+        Bus bus = ex.get(Bus.class);
+        PhaseManager pm = bus.getExtension(PhaseManager.class);
+        PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases());
+        
+        Endpoint ep = ex.get(Endpoint.class);
+        chain.add(ep.getOutInterceptors());
+        chain.add(ep.getService().getOutInterceptors());
+        chain.add(bus.getOutInterceptors());        
+        if (ep.getBinding() != null) {
+            chain.add(ep.getBinding().getOutInterceptors());
         }
-        outMessage.setInterceptorChain(chain);
+        
+        return chain;
     }
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/WrappedInInterceptor.java Mon Sep 25 06:26:03 2006
@@ -52,7 +52,8 @@
 
         // Trying to find the operation name from the XML.
         if (!StaxUtils.toNextElement(xmlReader)) {
-            throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT", BUNDLE));
+            // body may be empty for partial response to decoupled request
+            return;
         }
         BindingOperationInfo operation = message.getExchange().get(BindingOperationInfo.class);
         boolean requestor = isRequestor(message);

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java Mon Sep 25 06:26:03 2006
@@ -49,7 +49,8 @@
         HandlerChainInvoker invoker = 
             message.getExchange().get(HandlerChainInvoker.class);
         if (null == invoker) {
-            invoker = new HandlerChainInvoker(binding.getHandlerChain());
+            invoker = new HandlerChainInvoker(binding.getHandlerChain(),
+                                              isOutbound(message));
             message.getExchange().put(HandlerChainInvoker.class, invoker);
         }
         return invoker;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java Mon Sep 25 06:26:03 2006
@@ -98,14 +98,17 @@
                 messageInfo = op.getOutput();
                 bmi = boi2.getOutput();
             }
+                        
+            List<?> lst = message.getContent(List.class);
             
-            message.put(MessageInfo.class, messageInfo);
-            message.put(BindingMessageInfo.class, bmi);
-            message.getExchange().put(BindingOperationInfo.class, boi2);
-            message.getExchange().put(OperationInfo.class, op);
+            if (lst != null) {
+                message.put(MessageInfo.class, messageInfo);
+                message.put(BindingMessageInfo.class, bmi);
+                message.getExchange().put(BindingOperationInfo.class, boi2);
+                message.getExchange().put(OperationInfo.class, op);
+            }
             
-            List<?> lst = message.getContent(List.class);
-            if (lst.size() == 1) {
+            if (lst != null && lst.size() == 1) {
                 if (messageInfo.getMessageParts().size() > 0) {
                     Object wrappedObject = lst.get(0);
                     lst.clear();

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/ServletDestination.java Mon Sep 25 06:26:03 2006
@@ -458,8 +458,7 @@
     }
     
     protected boolean isOneWay(Message message) {
-        Boolean oneway = (Boolean)message.get(org.apache.cxf.message.Message.ONEWAY_MESSAGE);
-        return oneway != null && oneway.booleanValue();
+        return message.getExchange() != null && message.getExchange().isOneWay();
     }
 
 }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java Mon Sep 25 06:26:03 2006
@@ -43,8 +43,6 @@
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 
-import static org.apache.cxf.message.Message.ONEWAY_MESSAGE;
-
 
 /**
  * Common base for HTTP Destination implementations.
@@ -146,8 +144,7 @@
      * @return true iff the message has been marked as oneway
      */    
     protected boolean isOneWay(Message message) {
-        Boolean oneway = (Boolean)message.get(ONEWAY_MESSAGE);
-        return oneway != null && oneway.booleanValue();
+        return message.getExchange() != null && message.getExchange().isOneWay();
     }
 
     /**

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Mon Sep 25 06:26:03 2006
@@ -36,7 +36,6 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.wsdl.WSDLException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
@@ -47,6 +46,7 @@
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.io.AbstractWrappedOutputStream;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -69,6 +69,13 @@
 
     public static final String HTTP_CONNECTION = "http.connection";
     
+    /**
+     * REVISIT: temporary mechanism to allow decoupled response endpoint
+     * to be configured, pending the maturation on the real config model
+     */
+    public static final String HTTP_DECOUPLED_ENDPOINT =
+        "http.decoupled.endpoint";
+    
     private static final Logger LOG = LogUtils.getL7dLogger(HTTPConduit.class);
     private final Bus bus;
     private final URLConnectionFactory connectionFactory;
@@ -133,7 +140,9 @@
                             ? factory
                             : getDefaultConnectionFactory();
         decoupledEngine = eng;
-        url = new URL(getAddress());
+        url = t == null
+              ? new URL(getAddress())
+              : new URL(t.getAddress().getValue());
         target = getTargetReference(t);
     }
     
@@ -205,7 +214,7 @@
      */
     public synchronized Destination getBackChannel() {
         if (decoupledDestination == null
-            && getClient().getDecoupledEndpoint() != null) {
+            && getConfiguredDecoupledEndpoint() != null) {
             decoupledDestination = setUpDecoupledDestination(); 
         }
         return decoupledDestination;
@@ -348,7 +357,7 @@
      */
     private DecoupledDestination setUpDecoupledDestination() {        
         EndpointReferenceType reference =
-            EndpointReferenceUtils.getEndpointReference(getClient().getDecoupledEndpoint());
+            EndpointReferenceUtils.getEndpointReference(getConfiguredDecoupledEndpoint());
         if (reference != null) {
             String decoupledAddress = reference.getAddress().getValue();
             LOG.info("creating decoupled endpoint: " + decoupledAddress);
@@ -374,6 +383,16 @@
         }
         return new DecoupledDestination(reference, incomingObserver);
     }
+    
+    /**
+     * REVISIT: temporary mechanism to allow decoupled response endpoint
+     * to be configured, pending the maturation on the real config model
+     */
+    private String getConfiguredDecoupledEndpoint() {
+        return getClient().getDecoupledEndpoint() != null
+               ? getClient().getDecoupledEndpoint()
+               : System.getProperty(HTTP_DECOUPLED_ENDPOINT);
+    }
 
     /**
      * Wrapper output stream responsible for flushing headers and handling
@@ -410,10 +429,9 @@
         }
 
         private void handleResponse() throws IOException {
-            // REVISIT distinguish decoupled case
             Exchange exchange = outMessage.getExchange();
             if (exchange != null && exchange.isOneWay()) {
-                //onway operation
+                //oneway operation
                 connection.getInputStream().close();
                 return;
             }
@@ -445,18 +463,23 @@
     private class WrapperInputStream extends FilterInputStream {
         HttpRequest request;
         HttpResponse response;
+        boolean closed;
         
-        WrapperInputStream(HttpRequest req,
+        WrapperInputStream(InputStream is,
+                           HttpRequest req,
                            HttpResponse resp) {
-            super(req.getInputStream());
+            super(is);
             request = req;
             response = resp;
         }
         
         public void close() throws IOException {
-            super.close();            
-            response.commit();
-            request.setHandled(true);
+            if (!closed) {
+                closed = true;
+                response.commit();
+                request.setHandled(true);
+                super.close();            
+            }
         }
     }
     
@@ -480,7 +503,7 @@
         public Conduit getBackChannel(Message inMessage,
                                       Message partialResponse,
                                       EndpointReferenceType addr)
-            throws WSDLException, IOException {
+            throws IOException {
             // shouldn't be called on decoupled endpoint
             return null;
         }
@@ -519,13 +542,22 @@
                            String pathParams,
                            HttpRequest req,
                            HttpResponse resp) throws IOException {
+            InputStream responseStream = req.getInputStream();
             Message inMessage = new MessageImpl();
-            inMessage.put(Message.PROTOCOL_HEADERS, req.getParameters());
+            // disposable exchange, swapped with real Exchange on correlation
+            inMessage.setExchange(new ExchangeImpl());
+            // REVISIT: how to get response headers?
+            //inMessage.put(Message.PROTOCOL_HEADERS, req.getXXX());
+            setHeaders(inMessage);
             inMessage.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_OK);
-            InputStream is = new WrapperInputStream(req, resp);
+            InputStream is = new WrapperInputStream(responseStream, req, resp);
             inMessage.setContent(InputStream.class, is);
 
-            decoupledDestination.getMessageObserver().onMessage(inMessage);
+            try {
+                decoupledDestination.getMessageObserver().onMessage(inMessage);    
+            } finally {
+                is.close();
+            }
         }
     }    
 

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPDestination.java Mon Sep 25 06:26:03 2006
@@ -38,6 +38,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.io.AbstractWrappedOutputStream;
+import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -46,6 +47,7 @@
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
 import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 import org.mortbay.http.HttpRequest;
 import org.mortbay.http.HttpResponse;
@@ -59,6 +61,9 @@
     public static final String HTTP_RESPONSE =
         JettyHTTPDestination.class.getName() + ".RESPONSE";
     
+    protected static final String ANONYMOUS_ADDRESS =
+        "http://www.w3.org/2005/08/addressing/anonymous";
+    
     protected ServerEngine engine;
     protected MessageObserver incomingObserver;
 
@@ -158,16 +163,21 @@
         throws IOException {
         HttpResponse response = (HttpResponse)inMessage.get(HTTP_RESPONSE);
         Conduit backChannel = null;
-        if (address == null) {
-            backChannel = new BackChannelConduit(address, response);
+        Exchange ex = inMessage.getExchange();
+        EndpointReferenceType target = address != null
+                                       ? address
+                                       : ex.get(EndpointReferenceType.class);
+        if (target == null) {
+            backChannel = new BackChannelConduit(response);
         } else {
             if (partialResponse != null) {
                 // setup the outbound message to for 202 Accepted
                 partialResponse.put(Message.RESPONSE_CODE,
                                     HttpURLConnection.HTTP_ACCEPTED);
-                backChannel = new BackChannelConduit(address, response);
+                backChannel = new BackChannelConduit(response);
+                ex.put(EndpointReferenceType.class, target);
             } else {
-                backChannel = conduitInitiator.getConduit(endpointInfo, address);
+                backChannel = conduitInitiator.getConduit(endpointInfo, target);
                 // ensure decoupled back channel input stream is closed
                 backChannel.setMessageObserver(new MessageObserver() {
                     public void onMessage(Message m) {
@@ -349,9 +359,10 @@
         protected HttpResponse response;
         protected EndpointReferenceType target;
         
-        BackChannelConduit(EndpointReferenceType ref, HttpResponse resp) {
+        BackChannelConduit(HttpResponse resp) {
             response = resp;
-            target = ref;
+            target =
+                EndpointReferenceUtils.getEndpointReference(ANONYMOUS_ADDRESS);
         }
         public void close(Message msg) throws IOException {
             msg.getContent(OutputStream.class).close();        

Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/HTTPConduitTest.java Mon Sep 25 06:26:03 2006
@@ -396,9 +396,9 @@
         assertEquals("unexpected getInputStream count",
                      1,
                      decoupledRequest.getInputStreamCallCount());
-        assertEquals("unexpected getParameters counts",
-                     1,
-                     decoupledRequest.getParametersCallCount());
+        //assertEquals("unexpected getParameters counts",
+        //             1,
+        //             decoupledRequest.getParametersCallCount());
         assertTrue("unexpected content formats",
                    inMessage.getContentFormats().contains(InputStream.class));
         InputStream decoupledIS = inMessage.getContent(InputStream.class);

Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPDestinationTest.java Mon Sep 25 06:26:03 2006
@@ -37,6 +37,7 @@
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.io.AbstractCachedOutputStream;
+import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -50,9 +51,6 @@
 import org.easymock.classextension.IMocksControl;
 import org.mortbay.http.handler.AbstractHttpHandler;
 
-import static org.apache.cxf.message.Message.ONEWAY_MESSAGE;
-
-
 public class JettyHTTPDestinationTest extends TestCase {
     protected static final String AUTH_HEADER = "Authorization";
     protected static final String USER = "copernicus";
@@ -145,7 +143,11 @@
     
     public void testDoServiceWithHttpGET() throws Exception {
         destination = setUpDestination(false);
-        setUpDoService(false, false, false, "GET", "?customerId=abc&cutomerAdd=def");
+        setUpDoService(false,
+                       false,
+                       false,
+                       "GET",
+                       "?customerId=abc&cutomerAdd=def");
         destination.doService(request, response);
         
         assertNotNull("unexpected null message", inMessage);
@@ -165,42 +167,46 @@
         destination = setUpDestination(false);
         setUpDoService(false);
         destination.doService(request, response);
+        setUpInMessage();
         Conduit backChannel = destination.getBackChannel(inMessage, null, null);
         
         assertNotNull("expected back channel", backChannel);
         assertNull("unexpected backchannel-backchannel",
                    backChannel.getBackChannel());
-        assertSame("unexpected target",
-                   replyTo,
-                   backChannel.getTarget());
+        assertEquals("unexpected target",
+                     JettyHTTPDestination.ANONYMOUS_ADDRESS,
+                     backChannel.getTarget().getAddress().getValue());
     }
     
     public void testGetBackChannelSend() throws Exception {
         destination = setUpDestination(false);
         setUpDoService(false, true);
         destination.doService(request, response);
+        setUpInMessage();
         Conduit backChannel =
             destination.getBackChannel(inMessage, null, null);
         outMessage = setUpOutMessage();
         backChannel.send(outMessage);
         verifyBackChannelSend(backChannel, outMessage, 200);
     }
+
     public void testGetBackChannelSendFault() throws Exception {
         destination = setUpDestination(false);
         setUpDoService(false, true);
         destination.doService(request, response);
+        setUpInMessage();
         Conduit backChannel =
             destination.getBackChannel(inMessage, null, null);
         outMessage = setUpOutMessage();
         backChannel.send(outMessage);
         verifyBackChannelSend(backChannel, outMessage, 500);
     }
-
     
     public void testGetBackChannelSendOneway() throws Exception {
         destination = setUpDestination(false);
         setUpDoService(false, true);
         destination.doService(request, response);
+        setUpInMessage();
         Conduit backChannel =
             destination.getBackChannel(inMessage, null, null);
         outMessage = setUpOutMessage();
@@ -213,6 +219,7 @@
         replyTo = getEPR(NOWHERE + "response/foo");
         setUpDoService(false, true, true);
         destination.doService(request, response);
+        setUpInMessage();
         
         Message partialResponse = setUpOutMessage();
         Conduit partialBackChannel =
@@ -354,10 +361,16 @@
         control.replay();
     }
     
+    private void setUpInMessage() {
+        inMessage.setExchange(new ExchangeImpl());
+    }
+    
     private Message setUpOutMessage() {
         Message outMsg = new MessageImpl();
         outMsg.putAll(inMessage);
-        outMsg.put(Message.PROTOCOL_HEADERS, new HashMap<String, List<String>>());
+        outMsg.setExchange(new ExchangeImpl());
+        outMsg.put(Message.PROTOCOL_HEADERS,
+                   new HashMap<String, List<String>>());
         return outMsg;
     }
     
@@ -427,7 +440,8 @@
         assertEquals("unexpected values", 1, values.size());
         assertTrue("expected value", values.contains(BASIC_AUTH));
         
-        AuthorizationPolicy authpolicy = inMessage.get(AuthorizationPolicy.class);
+        AuthorizationPolicy authpolicy =
+            inMessage.get(AuthorizationPolicy.class);
         assertNotNull("Expected some auth tokens", policy);
         assertEquals("expected user",
                      USER,
@@ -492,9 +506,7 @@
         assertEquals("expected getOutputStream",
                      0,
                      response.getOutputStreamCallCount());
-        if (oneway) {
-            outMsg.put(ONEWAY_MESSAGE, Boolean.TRUE);
-        }
+        outMsg.getExchange().setOneWay(oneway);
         responseOS.flush();
         assertEquals("expected setStatus",
                      1,
@@ -512,7 +524,8 @@
                      1,
                      response.getOutputStreamCallCount());
         underlyingOS = ((AbstractCachedOutputStream)responseOS).getOut();
-        assertFalse("unexpected underlying output stream type: " + underlyingOS.getClass(),
+        assertFalse("unexpected underlying output stream type: "
+                    + underlyingOS.getClass(),
                     underlyingOS instanceof ByteArrayOutputStream);
         assertEquals("expected commit",
                      oneway ? 2 : 1,

Modified: incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java (original)
+++ incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java Mon Sep 25 06:26:03 2006
@@ -37,7 +37,6 @@
 import javax.jms.Topic;
 import javax.jms.TopicPublisher;
 import javax.naming.NamingException;
-import javax.wsdl.WSDLException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
@@ -336,6 +335,9 @@
             //TODO if outMessage need to get the response
             Message inMessage = new MessageImpl();
             inMessage.setExchange(outMessage.getExchange());            
+            //set the message header back to the incomeMessage
+            //inMessage.put(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS, 
+            //              outMessage.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS));
                         
             try {
                 response = receive(pooledSession, outMessage);
@@ -343,9 +345,11 @@
                 LOG.log(Level.FINE, "JMS connect failed with JMSException : ", jmsex);            
                 throw new IOException(jmsex.toString());
             }  
+
             //set the message header back to the incomeMessage
             inMessage.put(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS, 
                           outMessage.get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS));
+
             LOG.log(Level.FINE, "The Response Message is : [" + response + "]");
             
             // setup the inMessage response stream
@@ -383,7 +387,7 @@
         public Conduit getBackChannel(Message inMessage,
                                       Message partialResponse,
                                       EndpointReferenceType addr)
-            throws WSDLException, IOException {
+            throws IOException {
             // shouldn't be called on decoupled endpoint
             return null;
         }

Modified: incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java (original)
+++ incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java Mon Sep 25 06:26:03 2006
@@ -44,7 +44,6 @@
 
 import javax.jms.TextMessage;
 import javax.naming.NamingException;
-import javax.wsdl.WSDLException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
@@ -96,7 +95,7 @@
 
     public Conduit getBackChannel(Message inMessage, 
                                   Message partialResponse, 
-                                  EndpointReferenceType address) throws WSDLException, IOException {
+                                  EndpointReferenceType address) throws IOException {
                 
         Conduit backChannel = null;
         if (address == null) {

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java Mon Sep 25 06:26:03 2006
@@ -33,20 +33,18 @@
 import javax.xml.ws.ResponseWrapper;
 import javax.xml.ws.WebFault;
 
-import static javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY;
-
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.OutgoingChainSetupInterceptor;
+import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
 
-import static org.apache.cxf.message.Message.CORRELATION_IN;
-import static org.apache.cxf.message.Message.CORRELATION_OUT;
-import static org.apache.cxf.message.Message.ONEWAY_MESSAGE;
 import static org.apache.cxf.message.Message.REQUESTOR_ROLE;
 
 import static org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES;
@@ -106,8 +104,10 @@
     * @return true iff the message direction is outbound
     */
     public static boolean isOutbound(Message message) {
-        Boolean outbound = (Boolean)message.get(MESSAGE_OUTBOUND_PROPERTY);
-        return outbound != null && outbound.booleanValue();
+        Exchange exchange = message.getExchange();
+        return message != null
+               && exchange != null
+               && message == exchange.getOutMessage();
     }
 
    /**
@@ -122,17 +122,6 @@
     }
 
     /**
-     * Determine if current invocation is oneway.
-     *
-     * @param message the current Message
-     * @return true iff the current invocation is oneway
-     */
-    public static boolean isOneway(Message message) {
-        Boolean oneway = (Boolean)message.get(ONEWAY_MESSAGE);
-        return oneway != null && oneway.booleanValue();
-    }
-
-    /**
      * Get appropriate property name for message addressing properties.
      *
      * @param isProviderContext true if the binding provider request context 
@@ -156,18 +145,6 @@
                  ? SERVER_ADDRESSING_PROPERTIES_OUTBOUND
                  : SERVER_ADDRESSING_PROPERTIES_INBOUND;
     }
-    
-    /**
-     * Get appropriate context property name for correlation ID.
-     *
-     * @param isOutbound true iff the message is outbound
-     * @return the property name to use when caching the 
-     * correlation ID in the context
-     */
-    public static String getCorrelationIDProperty(boolean isOutbound) {
-        return isOutbound ? CORRELATION_OUT : CORRELATION_IN;
-    }
-
 
     /**
      * Store MAPs in the message.
@@ -178,7 +155,7 @@
     public static void storeMAPs(AddressingProperties maps,
                                  Message message,
                                  boolean isOutbound) {
-        storeMAPs(maps, message, isOutbound, isRequestor(message), true, false);
+        storeMAPs(maps, message, isOutbound, isRequestor(message), false);
     }
 
     /**
@@ -194,9 +171,8 @@
     public static void storeMAPs(AddressingProperties maps,
                                  Message message,
                                  boolean isOutbound, 
-                                 boolean isRequestor,
-                                 boolean handler) {
-        storeMAPs(maps, message, isOutbound, isRequestor, handler, false);
+                                 boolean isRequestor) {
+        storeMAPs(maps, message, isOutbound, isRequestor, false);
     }
     
     /**
@@ -214,7 +190,6 @@
                                  Message message,
                                  boolean isOutbound, 
                                  boolean isRequestor,
-                                 boolean handler,
                                  boolean isProviderContext) {
         if (maps != null) {
             String mapProperty = getMAPProperty(isRequestor, isProviderContext, isOutbound);
@@ -315,42 +290,90 @@
     }
     
     /**
-     * Rebase server transport on replyTo
+     * Rebase response on replyTo
      * 
      * @param reference the replyTo reference
      * @param namespaceURI determines the WS-A version
      * @param inMessage the current message
      */
-    public static void rebaseTransport(EndpointReferenceType reference,
-                                       String namespaceURI,
-                                       Message inMessage) {
+    public static void rebaseResponse(EndpointReferenceType reference,
+                                      AddressingProperties inMAPs,
+                                      Message inMessage) {
+        String namespaceURI = inMAPs.getNamespaceURI();
         if (!retrievePartialResponseSent(inMessage)) {
-            // ensure there is a MAPs instance available for the outbound
-            // partial response that contains appropriate To and ReplyTo
-            // properties (i.e. anonymous & none respectively)
-            AddressingPropertiesImpl maps = new AddressingPropertiesImpl();
-            maps.setTo(ContextUtils.getAttributedURI(Names.WSA_ANONYMOUS_ADDRESS));
-            maps.setReplyTo(WSA_OBJECT_FACTORY.createEndpointReferenceType());
-            maps.getReplyTo().setAddress(getAttributedURI(Names.WSA_NONE_ADDRESS));
-            maps.setAction(getAttributedURI(""));
-            maps.exposeAs(namespaceURI);
-            Message partialResponse = new MessageImpl();
-            storeMAPs(maps, partialResponse, true, true, true, true);
-
+            Exchange exchange = inMessage.getExchange();
+            Message fullResponse = exchange.getOutMessage();
+            Endpoint endpoint = exchange.get(Endpoint.class);
+            Message partialResponse = endpoint.getBinding().createMessage();
+            ensurePartialResponseMAPs(partialResponse, namespaceURI);
+            
+            // ensure the inbound MAPs are available in both the full, fault
+            // and partial response messages (used to determine relatesTo etc.)
+            propogateReceivedMAPs(inMAPs, partialResponse);
+            propogateReceivedMAPs(inMAPs, fullResponse);
+            propogateReceivedMAPs(inMAPs, exchange.getFaultMessage());
+            
             try {
                 Destination target = inMessage.getDestination();
                 Conduit backChannel = target.getBackChannel(inMessage,
                                                             partialResponse,
                                                             reference);
                 if (backChannel != null) {
-                    // REVISIT set up interceptor chains and send message
+                    // set up interceptor chains and send message
+
+                    exchange.setOutMessage(partialResponse);
+                    InterceptorChain chain =
+                        fullResponse != null
+                        ? fullResponse.getInterceptorChain()
+                        : OutgoingChainSetupInterceptor.getOutInterceptorChain(exchange);
+                    partialResponse.setInterceptorChain(chain);
+                    exchange.setConduit(backChannel);
                     
+                    partialResponse.getInterceptorChain().doIntercept(partialResponse);
+                    
+                    partialResponse.getInterceptorChain().reset();
+                    exchange.setConduit(null);
+                    exchange.setOutMessage(fullResponse);
                 }
             } catch (Exception e) {
                 LOG.log(Level.WARNING, "SERVER_TRANSPORT_REBASE_FAILURE_MSG", e);
             }
         } 
     }
+    
+    /**
+     * Propogate inbound MAPs onto reponse message if applicable
+     * (not applicable for oneways).
+     * 
+     * @param inMAPs the inbound MAPs
+     * @param responseMessage
+     */
+    private static void propogateReceivedMAPs(AddressingProperties inMAPs,
+                                               Message responseMessage) {
+        if (responseMessage != null) {
+            storeMAPs(inMAPs, responseMessage, false, false, false);
+        }
+    }
+    
+    /**
+     * Construct and store MAPs for partial response.
+     * 
+     * @param partialResponse the partial response message
+     * @param namespaceURI the current namespace URI
+     */
+    private static void ensurePartialResponseMAPs(Message partialResponse,
+                                                 String namespaceURI) {
+        // ensure there is a MAPs instance available for the outbound
+        // partial response that contains appropriate To and ReplyTo
+        // properties (i.e. anonymous & none respectively)
+        AddressingPropertiesImpl maps = new AddressingPropertiesImpl();
+        maps.setTo(ContextUtils.getAttributedURI(Names.WSA_ANONYMOUS_ADDRESS));
+        maps.setReplyTo(WSA_OBJECT_FACTORY.createEndpointReferenceType());
+        maps.getReplyTo().setAddress(getAttributedURI(Names.WSA_NONE_ADDRESS));
+        maps.setAction(getAttributedURI(""));
+        maps.exposeAs(namespaceURI);
+        storeMAPs(maps, partialResponse, true, true, false);
+    }
 
     /**
      * Store bad MAP fault name in the message.
@@ -393,57 +416,6 @@
     public static String retrieveMAPFaultReason(Message message) {
         return (String)message.get(MAP_FAULT_REASON_PROPERTY);
     }
-
-    /**
-     * Store correlation ID in the context
-     *
-     * @param id the correlation ID
-     * @param isOutbound true if message is outbound
-     * @param message the current message
-     */   
-    public static void storeCorrelationID(RelatesToType id, 
-                                          boolean isOutbound,
-                                          Message message) {
-        storeCorrelationID(id.getValue(), isOutbound, message);
-    }
-    
-    /**
-     * Store correlation ID in the context
-     *
-     * @param id the correlation ID
-     * @param isOutbound true if message is outbound
-     * @param message the current message
-     */   
-    public static void storeCorrelationID(AttributedURIType id, 
-                                          boolean isOutbound,
-                                          Message message) {
-        storeCorrelationID(id.getValue(), isOutbound, message);
-    }
-    
-    /**
-     * Store correlation ID in the context
-     *
-     * @param id the correlation ID
-     * @param isOutbound true if message is outbound
-     * @param message the current message
-     */   
-    protected static void storeCorrelationID(String id, 
-                                           boolean isOutbound,
-                                           Message message) {
-        message.put(getCorrelationIDProperty(isOutbound), id);
-    }
-    
-    /**
-     * Retrieve correlation ID from the message.
-     *
-     * @param message the current message
-     * @param isOutbound true if message is outbound
-     * @returned the retrieved correlation ID
-     */
-    public static String retrieveCorrelationID(Message message, 
-                                               boolean isOutbound) {
-        return (String)message.get(getCorrelationIDProperty(isOutbound));
-    }
     
     /**
      * Store an indication that a partial response has been sent.
@@ -506,6 +478,21 @@
     }
     
     /**
+     * Retreive Conduit from Exchange if not already available
+     * 
+     * @param conduit the current value for the Conduit
+     * @param message the current message
+     * @return the Conduit if available
+     */
+    public static Conduit getConduit(Conduit conduit, Message message) {
+        if (conduit == null) {
+            Exchange exchange = message.getExchange();
+            conduit = exchange != null ? exchange.getConduit() : null;
+        }
+        return conduit;
+    }
+    
+    /**
      * Construct the Action URI.
      * 
      * @param message the current message
@@ -522,10 +509,12 @@
         if (method != null) {
             if (fault != null) {
                 WebFault webFault = fault.getClass().getAnnotation(WebFault.class);
-                action = getAction(webFault.targetNamespace(),
-                                   method, 
-                                   webFault.name(),
-                                   true);
+                if (webFault != null) {
+                    action = getAction(webFault.targetNamespace(),
+                                       method, 
+                                       webFault.name(),
+                                       true);
+                }
             } else {
                 if (ContextUtils.isRequestor(message)) {
                     RequestWrapper requestWrapper =
@@ -558,17 +547,18 @@
                         WebService wsAnnotation = method.getDeclaringClass().getAnnotation(WebService.class);
                         WebMethod wmAnnotation = method.getAnnotation(WebMethod.class);
                         
-                        action = getAction(wsAnnotation.targetNamespace(),
-                                           method,
-                                           wmAnnotation.operationName(),
-                                           false);
+                        if (wsAnnotation != null && wmAnnotation != null) {
+                            action = getAction(wsAnnotation.targetNamespace(),
+                                               method,
+                                               wmAnnotation.operationName(),
+                                               false);
+                        }
                     }
                 }
             }
         }
         return action != null ? getAttributedURI(action) : null;
     }
-        
 
     /**
      * Construct the Action string.

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Mon Sep 25 06:26:03 2006
@@ -34,6 +34,7 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -53,6 +54,10 @@
     private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
     
 
+    /**
+     * REVISIT: map usage implies that the *same* interceptor instance 
+     * is used in all chains.
+     */
     protected final Map<String, String> messageIDs = 
         new HashMap<String, String>();
     
@@ -171,13 +176,14 @@
             // responder validates incoming MAPs
             AddressingPropertiesImpl maps = getMAPs(message, false, false);
             setUsingAddressing(true);
-            continueProcessing = validateIncomingMAPs(maps, message); 
+            boolean isOneway = message.getExchange().isOneWay();
+            continueProcessing = validateIncomingMAPs(maps, message);
             if (continueProcessing) {
-                if (ContextUtils.isOneway(message)
+                if (isOneway
                     || !ContextUtils.isGenericAddress(maps.getReplyTo())) {
-                    ContextUtils.rebaseTransport(maps.getReplyTo(),
-                                                 maps.getNamespaceURI(),
-                                                 message);
+                    ContextUtils.rebaseResponse(maps.getReplyTo(),
+                                                maps,
+                                                message);
                 }            
             } else {
                 // validation failure => dispatch is aborted, response MAPs 
@@ -204,7 +210,7 @@
         // b) message is currently inbound, but we are about to abort dispatch
         //    due to an incoming MAPs validation failure, so the dispatch
         //    will shortly traverse the outbound path
-        ContextUtils.storeMAPs(maps, message, true, isRequestor, true);
+        ContextUtils.storeMAPs(maps, message, true, isRequestor);
     }
 
     /**
@@ -215,21 +221,11 @@
      */
     private AddressingPropertiesImpl assembleGeneric(Message message) {
         AddressingPropertiesImpl maps = getMAPs(message, true, true);
-        // MessageID
+        // MessageID        
         if (maps.getMessageID() == null) {
             String messageID = ContextUtils.generateUUID();
             maps.setMessageID(ContextUtils.getAttributedURI(messageID));
         }
-        // To
-        if (maps.getTo() == null) {
-            Conduit conduit = message.getConduit();
-            EndpointReferenceType reference = conduit != null
-                                              ? conduit.getTarget()
-                                              : null;
-            maps.setTo(reference != null 
-                       ? reference.getAddress()
-                       : ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS));
-        }
         // Action
         if (ContextUtils.hasEmptyAction(maps)) {
             maps.setAction(ContextUtils.getAction(message));
@@ -251,16 +247,34 @@
                                  boolean isRequestor,
                                  boolean isFault) {
         if (isRequestor) {
+            Exchange exchange = message.getExchange();
+            
             // add request-specific MAPs
-            boolean isOneway = ContextUtils.isOneway(message);
+            boolean isOneway = exchange.isOneWay();
+            boolean isOutbound = ContextUtils.isOutbound(message);
+            Conduit conduit = null;
+            
+            // To
+            if (maps.getTo() == null) {
+                if (isOutbound) {
+                    conduit = ContextUtils.getConduit(conduit, message);
+                }
+                EndpointReferenceType reference = conduit != null
+                                                  ? conduit.getTarget()
+                                                  : null;
+                maps.setTo(reference != null 
+                           ? reference.getAddress()
+                           : ContextUtils.getAttributedURI(Names.WSA_NONE_ADDRESS));
+            }
+
             // ReplyTo, set if null in MAPs or if set to a generic address
             // (anonymous or none) that may not be appropriate for the
             // current invocation
             EndpointReferenceType replyTo = maps.getReplyTo();
             if (ContextUtils.isGenericAddress(replyTo)) {
-                Conduit conduit = message.getConduit();
+                conduit = ContextUtils.getConduit(conduit, message);
                 if (conduit != null) {
-                    Destination backChannel = message.getConduit().getBackChannel();
+                    Destination backChannel = conduit.getBackChannel();
                     if (backChannel != null) {
                         replyTo = backChannel.getAddress();
                     }
@@ -279,10 +293,6 @@
             if (!isOneway) {
                 // REVISIT FaultTo if cached by transport in message
             }
-            // cache correlation ID
-            if (ContextUtils.isOutbound(message)) {
-                ContextUtils.storeCorrelationID(maps.getMessageID(), true, message);
-            }
         } else {
             // add response-specific MAPs
             AddressingPropertiesImpl inMAPs = getMAPs(message, false, false);
@@ -299,9 +309,9 @@
 
             if (isFault
                 && !ContextUtils.isGenericAddress(inMAPs.getFaultTo())) {
-                ContextUtils.rebaseTransport(inMAPs.getFaultTo(),
-                                             inMAPs.getNamespaceURI(),
-                                             message);
+                ContextUtils.rebaseResponse(inMAPs.getFaultTo(),
+                                            inMAPs,
+                                            message);
             }
         }
     }

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java Mon Sep 25 06:26:03 2006
@@ -149,6 +149,7 @@
         "http://www.w3.org/2003/05/soap-envelope?addressing=ms";
     
     public static final String SOAP_ACTION_HEADER = "SOAPAction";
+    
     /**
      * The set of headers understood by the protocol binding.
      */

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?view=diff&rev=449679&r1=449678&r2=449679
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java Mon Sep 25 06:26:03 2006
@@ -20,6 +20,8 @@
 package org.apache.cxf.ws.addressing.soap;
 
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -46,6 +48,7 @@
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.message.Exchange;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
@@ -66,10 +69,17 @@
 
     private static final Logger LOG = LogUtils.getL7dLogger(MAPCodec.class);
     private static SOAPFactory soapFactory;
-    
-    private VersionTransformer transformer;
 
     /**
+     * REVISIT: map usage that the *same* interceptor instance 
+     * is used in all chains.
+     */
+    protected final Map<String, Exchange> uncorrelatedExchanges =
+        Collections.synchronizedMap(new HashMap<String, Exchange>());
+
+    private VersionTransformer transformer;
+    
+    /**
      * Constructor.
      */
     public MAPCodec() {
@@ -125,6 +135,7 @@
     private void encode(SoapMessage message, 
                         AddressingProperties maps) {
         if (maps != null) { 
+            cacheExchange(message, maps);
             LOG.log(Level.INFO, "encoding MAPs in SOAP headers");
             try {
                 Element header = message.getHeaders(Element.class);
@@ -263,6 +274,7 @@
                         }
                     }
                 }
+                restoreExchange(message, maps);
             }
         } catch (JAXBException je) {
             LOG.log(Level.WARNING, "SOAP_HEADER_DECODE_FAILURE_MSG", je); 
@@ -280,15 +292,7 @@
     private AddressingProperties decode(SoapMessage message) {
         // REVISIT generate MessageAddressingHeaderRequired fault if an
         // expected header is missing 
-        AddressingProperties maps = null;
-        boolean isRequestor = ContextUtils.isRequestor(message);
-        maps = unmarshalMAPs(message);
-        if (isRequestor && null != maps.getRelatesTo()) {
-            ContextUtils.storeCorrelationID(maps.getRelatesTo(),
-                                            false,
-                                            message);
-        }
-        return maps;
+        return unmarshalMAPs(message);
     }
 
     /**
@@ -423,6 +427,39 @@
         fault.setFaultString(reason);
         return new SOAPFaultException(fault);
     }
+    
+    /**
+     * Cache exchange for correlated response
+     * 
+     * @param message the current message
+     * @param maps the addressing properties
+     */
+    private void cacheExchange(SoapMessage message, AddressingProperties maps) {
+        if (maps.getRelatesTo() == null) {
+            uncorrelatedExchanges.put(maps.getMessageID().getValue(),
+                                      message.getExchange());
+        }
+    }
+    
+    /**
+     * Restore exchange for correlated response
+     * 
+     * @param message the current message
+     * @param maps the addressing properties
+     */
+    private void restoreExchange(SoapMessage message, AddressingProperties maps) {
+        if (maps.getRelatesTo() != null) {
+            // REVISIT remove if not partial response
+            Exchange correlatedExchange =
+                uncorrelatedExchanges.get(maps.getRelatesTo().getValue());
+            if (correlatedExchange != null) {
+                synchronized (correlatedExchange) {
+                    message.setExchange(correlatedExchange);
+                }
+            }
+        }
+    }
+
 }
 
 



Mime
View raw message