You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by wt...@apache.org on 2010/03/12 21:36:15 UTC

svn commit: r922420 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/feature/ main/java/org/apache/camel/component/cxf/interceptors/ test/java/org/apache/camel/component/cxf/ test/java/org/apache/camel/wsdl_first/ te...

Author: wtam
Date: Fri Mar 12 20:36:14 2010
New Revision: 922420

URL: http://svn.apache.org/viewvc?rev=922420&view=rev
Log:
[CAMEL-2544] Application SOAP 12 fault support in camel-cxf PAYLOAD mode

Added:
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java   (with props)
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl12.java   (with props)
Removed:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadFaultInInterceptor.java
Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
    camel/trunk/components/camel-cxf/src/test/resources/person.wsdl

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java?rev=922420&r1=922419&r2=922420&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java Fri Mar 12 20:36:14 2010
@@ -17,6 +17,7 @@
 
 package org.apache.camel.component.cxf.feature;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Logger;
 
@@ -66,5 +67,17 @@ public abstract class AbstractDataFormat
             }
         }
     }
+    
+      
+    @SuppressWarnings("rawtypes")
+    protected void removeInterceptors(List<Interceptor> interceptors,
+                                      Collection<Class> toBeRemovedInterceptors) {
+        for (Interceptor interceptor : interceptors) {
+            if (toBeRemovedInterceptors.contains(interceptor.getClass())) {
+                getLogger().info("removing the interceptor " + interceptor);
+                interceptors.remove(interceptor);
+            }
+        }
+    }
 
 }

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java?rev=922420&r1=922419&r2=922420&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java Fri Mar 12 20:36:14 2010
@@ -16,23 +16,26 @@
  */
 package org.apache.camel.component.cxf.feature;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.logging.Logger;
 
 import org.apache.camel.component.cxf.interceptors.DOMInInterceptor;
 import org.apache.camel.component.cxf.interceptors.DOMOutInterceptor;
 import org.apache.camel.component.cxf.interceptors.PayloadContentRedirectInterceptor;
-import org.apache.camel.component.cxf.interceptors.PayloadFaultInInterceptor;
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.Binding;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.interceptor.ClientFaultConverter;
 import org.apache.cxf.phase.Phase;
 
 /**
  * This feature just setting up the CXF endpoint interceptor for handling the
  * Message in PAYLOAD data format
  */
+@SuppressWarnings("rawtypes")
 public class PayLoadDataFormatFeature extends AbstractDataFormatFeature {
     private static final Logger LOG = LogUtils.getL7dLogger(PayLoadDataFormatFeature.class);
     // filter the unused phase
@@ -48,6 +51,14 @@ public class PayLoadDataFormatFeature ex
         Phase.POST_LOGICAL_ENDING
     };
     
+    private static final Collection<Class> REMOVING_FAULT_IN_INTERCEPTORS;
+    
+    static {
+        REMOVING_FAULT_IN_INTERCEPTORS = new ArrayList<Class>();
+        // remove ClientFaultConverter as it tries to unmarshal to java object.  
+        REMOVING_FAULT_IN_INTERCEPTORS.add(ClientFaultConverter.class);
+    }
+    
     @Override
     public void initialize(Client client, Bus bus) {
         removeInterceptorWhichIsInThePhases(client.getInInterceptors(), REMOVING_IN_PHASES);
@@ -60,11 +71,11 @@ public class PayLoadDataFormatFeature ex
         removeInterceptorWhichIsInThePhases(client.getEndpoint().getOutInterceptors(), REMOVING_OUT_PHASES);
         removeInterceptorWhichIsInThePhases(client.getEndpoint().getBinding().getOutInterceptors(), REMOVING_OUT_PHASES);
         
-        removeInterceptorWhichIsInThePhases(client.getInFaultInterceptors(), REMOVING_IN_PHASES);
-        removeInterceptorWhichIsInThePhases(client.getEndpoint().getService().getInFaultInterceptors(), REMOVING_IN_PHASES);
-        removeInterceptorWhichIsInThePhases(client.getEndpoint().getInFaultInterceptors(), REMOVING_IN_PHASES);
-        removeInterceptorWhichIsInThePhases(client.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_IN_PHASES);
-        
+        removeInterceptors(client.getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(client.getEndpoint().getService().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(client.getEndpoint().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(client.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+
         addDataHandlingInterceptors(client.getEndpoint().getBinding());        
     }
 
@@ -79,10 +90,10 @@ public class PayLoadDataFormatFeature ex
         removeInterceptorWhichIsInThePhases(server.getEndpoint().getOutInterceptors(), REMOVING_OUT_PHASES);
         removeInterceptorWhichIsInThePhases(server.getEndpoint().getBinding().getOutInterceptors(), REMOVING_OUT_PHASES);
         
-        removeInterceptorWhichIsInThePhases(server.getEndpoint().getService().getInFaultInterceptors(), REMOVING_IN_PHASES);
-        removeInterceptorWhichIsInThePhases(server.getEndpoint().getInFaultInterceptors(), REMOVING_IN_PHASES);
-        removeInterceptorWhichIsInThePhases(server.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_IN_PHASES);
-        
+        removeInterceptors(server.getEndpoint().getService().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(server.getEndpoint().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+        removeInterceptors(server.getEndpoint().getBinding().getInFaultInterceptors(), REMOVING_FAULT_IN_INTERCEPTORS);
+
         addDataHandlingInterceptors(server.getEndpoint().getBinding());        
     }
 
@@ -90,12 +101,12 @@ public class PayLoadDataFormatFeature ex
         binding.getInInterceptors().add(new DOMInInterceptor());
         binding.getOutInterceptors().add(new DOMOutInterceptor());
         binding.getOutInterceptors().add(new PayloadContentRedirectInterceptor());
-        binding.getInFaultInterceptors().add(new PayloadFaultInInterceptor());
     }
 
     @Override
     protected Logger getLogger() {
         return LOG;
     }
+    
 
 }

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java?rev=922420&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java Fri Mar 12 20:36:14 2010
@@ -0,0 +1,37 @@
+/**
+ * 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.camel.component.cxf;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.camel.wsdl_first.PersonImpl12;
+import org.junit.Before;
+
+public class CXFWsdlOnlyPayloadModeNoSpringSoap12Test extends CXFWsdlOnlyPayloadModeNoSpringTest {
+    
+    
+    @Before
+    public void startService() {
+        endpoint = Endpoint.publish("http://localhost:8093/PersonService", new PersonImpl12());
+    }
+    
+    @Override
+    protected String getServiceName() {
+        return "{http://camel.apache.org/wsdl-first}PersonService12";
+    }
+    
+}

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java?rev=922420&r1=922419&r2=922420&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java Fri Mar 12 20:36:14 2010
@@ -39,11 +39,10 @@ import org.junit.Test;
 
 public class CXFWsdlOnlyPayloadModeNoSpringTest extends CamelTestSupport {
     
-    protected static final String SERVICE_NAME = "{http://camel.apache.org/wsdl-first}PersonService";
-    protected static final String SERVICE_NAME_PROP =  "serviceName=" + SERVICE_NAME;
+    protected static final String SERVICE_NAME_PROP =  "serviceName=";
     protected static final String PORT_NAME_PROP = "portName={http://camel.apache.org/wsdl-first}soap";
     protected static final String WSDL_URL_PROP = "wsdlURL=classpath:person.wsdl";
-    private Endpoint endpoint;
+    protected Endpoint endpoint;
 
     @Before
     public void startService() {
@@ -62,8 +61,8 @@ public class CXFWsdlOnlyPayloadModeNoSpr
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("cxf://http://localhost:8092/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat())
-                    .to("cxf://http://localhost:8093/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat());
+                from("cxf://http://localhost:8092/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat())
+                    .to("cxf://http://localhost:8093/PersonService?" + PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + WSDL_URL_PROP + "&dataFormat=" + getDataFormat());
             }
         };
     }
@@ -75,7 +74,7 @@ public class CXFWsdlOnlyPayloadModeNoSpr
     @Test
     public void testRoutes() throws Exception {
         URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
-        PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
+        PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
 
         Person client = ss.getSoap();
         
@@ -95,7 +94,7 @@ public class CXFWsdlOnlyPayloadModeNoSpr
     @Test
     public void testApplicationFault() {
         URL wsdlURL = getClass().getClassLoader().getResource("person.wsdl");
-        PersonService ss = new PersonService(wsdlURL, QName.valueOf(SERVICE_NAME));
+        PersonService ss = new PersonService(wsdlURL, QName.valueOf(getServiceName()));
 
         Person client = ss.getSoap();
         
@@ -120,5 +119,7 @@ public class CXFWsdlOnlyPayloadModeNoSpr
         
     }
     
-    
+    protected String getServiceName() {
+        return "{http://camel.apache.org/wsdl-first}PersonService";
+    }
 }

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl12.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl12.java?rev=922420&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl12.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl12.java Fri Mar 12 20:36:14 2010
@@ -0,0 +1,29 @@
+/**
+ * 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.camel.wsdl_first;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "PersonService12",
+        targetNamespace = "http://camel.apache.org/wsdl-first",
+        endpointInterface = "org.apache.camel.wsdl_first.Person")
+        
+@javax.xml.ws.BindingType(value = "http://www.w3.org/2003/05/soap/bindings/HTTP/")                  
+public class PersonImpl12 extends PersonImpl {
+
+
+}

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl12.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/PersonImpl12.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-cxf/src/test/resources/person.wsdl
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/person.wsdl?rev=922420&r1=922419&r2=922420&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/person.wsdl (original)
+++ camel/trunk/components/camel-cxf/src/test/resources/person.wsdl Fri Mar 12 20:36:14 2010
@@ -21,6 +21,7 @@
 <wsdl:definitions name="wsdl-first"
 	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
 	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
 	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xmlns:tns="http://camel.apache.org/wsdl-first"
@@ -99,6 +100,22 @@
        </wsdl:operation>
    </wsdl:binding>
    
+   <wsdl:binding name="PersonSOAPBinding12" type="tns:Person">
+      <soap12:binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/" style="document" /> 
+      <wsdl:operation name="GetPerson">
+          <soap12:operation style="document" soapAction="GetPersonAction"/>		
+          <wsdl:input>
+              <soap12:body use="literal" />
+          </wsdl:input>
+          <wsdl:output>
+              <soap12:body use="literal" />
+          </wsdl:output>
+          <wsdl:fault name="UnknownPerson">
+              <soap12:fault use="literal" name="UnknownPerson" />
+          </wsdl:fault>
+      </wsdl:operation>
+   </wsdl:binding>   
+   
        <wsdl:binding name="PersonSOAPBinding2" type="tns:Person">
     	<soap:binding style="document" transport="http://cxf.apache.org/transports/camel" />
 		<wsdl:operation name="GetPerson">
@@ -125,5 +142,11 @@
        <soap:address location="camel://direct:camel.apache.org.wsdl-first.PersonService"/>
        </wsdl:port>
    </wsdl:service>
+   
+   <wsdl:service name="PersonService12">
+       <wsdl:port binding="tns:PersonSOAPBinding12" name="soap">
+       <soap12:address location="http://localhost:8092/PersonService/" />
+       </wsdl:port>
+   </wsdl:service>      
 
 </wsdl:definitions>