Author: andreasmyth
Date: Tue Jan  9 04:45:19 2007
New Revision: 494395

URL: http://svn.apache.org/viewvc?view=rev&rev=494395
Log:
[JIRA CXF-357] Identification of partial responses as client side inbound 
messages without a RelatesTo header - this fixes bug CXF-357 (test case added).
Reset client side timeout to 10 sec. and debug mode in ServerLauncher to false.
Small change to SoapHeaderInterceptor to make it less reliant on work 
previously done by BareInInterceptor.

Added:
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/DecoupledBareTest.java
   (with props)
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml
   (with props)
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
    
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.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/BareInInterceptor.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/soap/MAPCodec.java
    
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
    incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl

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=494395&r1=494394&r2=494395
==============================================================================
--- 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 
Tue Jan  9 04:45:19 2007
@@ -41,6 +41,7 @@
         "org.apache.cxf.async.post.response.dispatch";
 
     String DECOUPLED_CHANNEL_MESSAGE = "decoupled.channel.message";
+    String PARTIAL_RESPONSE_MESSAGE = "org.apache.cxf.partial.response";
     
     String USERNAME = Message.class.getName() + ".USERNAME";
     String PASSWORD = Message.class.getName() + ".PASSWORD";

Modified: 
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java?view=diff&rev=494395&r1=494394&r2=494395
==============================================================================
--- 
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
 (original)
+++ 
incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
 Tue Jan  9 04:45:19 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.binding.soap.interceptor;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.xml.namespace.QName;
@@ -56,6 +57,11 @@
         Exchange exchange = message.getExchange();
 
         List<Object> parameters = 
CastUtils.cast(message.getContent(List.class));
+
+        if (null == parameters) {
+            parameters = new ArrayList<Object>();
+        }
+
         BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
         if (bop.isUnwrapped()) {
             bop = bop.getWrappedOperation();
@@ -98,7 +104,9 @@
                 parameters.add(idx, object);
             }
         }
-        message.setContent(List.class, parameters);
+        if (parameters.size() > 0) {
+            message.setContent(List.class, parameters);
+        }
     }
 
     private Element findHeader(Element headerElement, MessagePartInfo mpi) {

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=494395&r1=494394&r2=494395
==============================================================================
--- 
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
 Tue Jan  9 04:45:19 2007
@@ -67,7 +67,7 @@
     protected Endpoint endpoint;
     protected Conduit initedConduit;
     protected ClientOutFaultObserver outFaultObserver; 
-    protected int synchronousTimeout = 10000000; // default 10 second timeout
+    protected int synchronousTimeout = 10000; // default 10 second timeout
 
     public ClientImpl(Bus b, Endpoint e) {
         this(b, e, null);
@@ -364,7 +364,6 @@
     }
 
     private boolean isPartialResponse(Message in) {
-        return in.getContent(List.class) == null
-               && getException(in.getExchange()) == null;
+        return Boolean.TRUE.equals(in.get(Message.PARTIAL_RESPONSE_MESSAGE));
     }
 }

Modified: 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java?view=diff&rev=494395&r1=494394&r2=494395
==============================================================================
--- 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
 (original)
+++ 
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
 Tue Jan  9 04:45:19 2007
@@ -125,6 +125,8 @@
             }
             paramNum++;
         }
-        message.setContent(List.class, parameters);
+        if (parameters.size() > 0) {
+            message.setContent(List.class, parameters);
+        }
     }
 }

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=494395&r1=494394&r2=494395
==============================================================================
--- 
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
 Tue Jan  9 04:45:19 2007
@@ -333,6 +333,7 @@
             // ensure the inbound MAPs are available in the partial response
             // message (used to determine relatesTo etc.)
             propogateReceivedMAPs(inMAPs, partialResponse);
+            partialResponse.put(Message.PARTIAL_RESPONSE_MESSAGE, 
Boolean.TRUE);
             
             try {
                 Destination target = inMessage.getDestination();

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=494395&r1=494394&r2=494395
==============================================================================
--- 
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
 Tue Jan  9 04:45:19 2007
@@ -307,7 +307,8 @@
                 maps.setTo(inMAPs.getReplyTo().getAddress());
             }
             // RelatesTo taken from MessageID in incoming MAPs
-            if (inMAPs.getMessageID() != null) {
+            if (inMAPs.getMessageID() != null
+                && 
!Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) {
                 String inMessageID = inMAPs.getMessageID().getValue();
                 maps.setRelatesTo(ContextUtils.getRelatesTo(inMessageID));
             }

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=494395&r1=494394&r2=494395
==============================================================================
--- 
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
 Tue Jan  9 04:45:19 2007
@@ -50,6 +50,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
@@ -305,6 +306,7 @@
                     }
                 }
                 restoreExchange(message, maps);
+                markPartialResponse(message, maps);
             }
         } catch (JAXBException je) {
             LOG.log(Level.WARNING, "SOAP_HEADER_DECODE_FAILURE_MSG", je); 
@@ -545,6 +547,17 @@
                 }
             }
         }
+    }
+
+    /**
+     * Marks a message as partial response
+     * 
+     * @param message the current message
+     */
+    private void markPartialResponse(SoapMessage message, AddressingProperties 
maps) {
+        if (ContextUtils.isRequestor(message) && null == maps.getRelatesTo()) {
+            message.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
+        } 
     }
 
 }

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/DecoupledBareTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/DecoupledBareTest.java?view=auto&rev=494395
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/DecoupledBareTest.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/DecoupledBareTest.java
 Tue Jan  9 04:45:19 2007
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.ws.rm;
+
+import java.util.logging.Logger;
+
+import javax.xml.ws.Endpoint;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.systest.common.ClientServerSetupBase;
+import org.apache.cxf.systest.common.ClientServerTestBase;
+import org.apache.cxf.systest.common.TestServerBase;
+import org.apache.hello_world_soap_http.DocLitBare;
+import org.apache.hello_world_soap_http.DocLitBareGreeterImpl;
+import org.apache.hello_world_soap_http.SOAPServiceAddressingDocLitBare;
+import org.apache.hello_world_soap_http.types.BareDocumentResponse;
+
+
+
+/**
+ * Tests the addition of WS-RM properties to application messages and the
+ * exchange of WS-RM protocol messages.
+ */
+public class DecoupledBareTest extends ClientServerTestBase {
+
+    private static final Logger LOG = 
Logger.getLogger(DecoupledBareTest.class.getName());
+    private Bus bus;
+
+    public static class Server extends TestServerBase {
+        
+        protected void run()  {            
+            SpringBusFactory bf = new SpringBusFactory();
+            Bus bus = 
bf.createBus("/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml");
+            bf.setDefaultBus(bus);
+            
+            Object implementor = new DocLitBareGreeterImpl();
+            String address = "http://localhost:7600/SoapContext/SoapPort";;
+            Endpoint.publish(address, implementor);
+            LOG.info("Published server endpoint.");
+        }
+        
+
+        public static void main(String[] args) {
+            try { 
+                Server s = new Server(); 
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally { 
+                System.out.println("done!");
+            }
+        }
+    }    
+    
+    public static Test suite() throws Exception {
+        TestSuite suite = new TestSuite(DecoupledBareTest.class);
+        return new ClientServerSetupBase(suite) {
+            public void startServers() throws Exception {
+                assertTrue("server did not launch correctly", 
launchServer(Server.class));
+            }
+            
+            public void setUp() throws Exception {
+                startServers();
+                LOG.fine("Started server.");  
+            }
+        };
+    }
+    
+    public void tearDown() {
+        bus.shutdown(true);
+    }
+    
+    public void testDecoupled() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        bus = 
bf.createBus("/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml");
+        bf.setDefaultBus(bus);
+       
+        SOAPServiceAddressingDocLitBare service = new 
SOAPServiceAddressingDocLitBare();
+        assertNotNull(service);
+
+        DocLitBare greeter = service.getSoapPort();
+       
+        BareDocumentResponse bareres = 
greeter.testDocLitBare("MySimpleDocument");
+        assertNotNull("no response for operation testDocLitBare", bareres);
+        assertEquals("CXF", bareres.getCompany());
+        assertTrue(bareres.getId() == 1);
+    }
+}

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/DecoupledBareTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/DecoupledBareTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml?view=auto&rev=494395
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml
 Tue Jan  9 04:45:19 2007
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xmlns:wsrm-mgmt="http://cxf.apache.org/ws/rm/manager";
+       xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy";
+       xmlns:http-conf="http://cxf.apache.org/transports/http/configuration";
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd";>
+    
+    <bean 
name="{http://apache.org/hello_world_soap_http}SoapPort.http-conduit"; 
abstract="true">
+        <property name="client">
+            <value>
+                <http-conf:client 
DecoupledEndpoint="http://localhost:9995/decoupled_endpoint"/>
+            </value>
+        </property>
+    </bean>
+    
+    <bean id="mapAggregator" 
class="org.apache.cxf.ws.addressing.MAPAggregator"/>
+    <bean id="mapCodec" class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>
+
+    <!-- We are adding the interceptors to the bus as we will have only one 
endpoint/service/bus. -->
+
+    <bean id="cxf" class="org.apache.cxf.bus.spring.SpringBusImpl">
+        <property name="inInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+        <property name="inFaultInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+        <property name="outInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+        <property name="outFaultInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+    </bean>
+
+</beans>
\ No newline at end of file

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/decoupled_bare.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: 
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java?view=diff&rev=494395&r1=494394&r2=494395
==============================================================================
--- 
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
 (original)
+++ 
incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
 Tue Jan  9 04:45:19 2007
@@ -48,7 +48,7 @@
     final String className;
 
 
-    private final boolean debug = true;
+    private final boolean debug = false;
     private boolean inProcess = DEFAULT_IN_PROCESS;
     private AbstractTestServerBase inProcessServer;
     

Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl?view=diff&rev=494395&r1=494394&r2=494395
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl 
(original)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/hello_world.wsdl Tue 
Jan  9 04:45:19 2007
@@ -329,6 +329,12 @@
             <soap:address 
location="http://localhost:7600/SoapContext/SoapPort"/>
         </wsdl:port>
     </wsdl:service>
+    <wsdl:service name="SOAPServiceAddressingDocLitBare">
+        <wsdl:port name="SoapPort" binding="tns:Doc_Lit_Bare_SOAPBinding">
+            <soap:address 
location="http://localhost:7600/SoapContext/SoapPort"/>
+            <wswa:UsingAddressing 
xmlns:wswa="http://www.w3.org/2005/08/addressing/wsdl"/>
+        </wsdl:port>
+    </wsdl:service>
     <wsdl:service name="SOAPService_Test1">
         <wsdl:port name="SoapPort_Test1" binding="tns:Greeter_SOAPBinding">
             <soap:address location="http://localhost:9100"/>


Reply via email to