Author: ningjiang
Date: Mon Mar 28 13:45:07 2011
New Revision: 1086231

URL: http://svn.apache.org/viewvc?rev=1086231&view=rev
Log:
CAMEL-3806 set the SOAPAction Header rightly from CXF message to Camel message

Modified:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringTest.java
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java

Modified: 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java?rev=1086231&r1=1086230&r2=1086231&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
 Mon Mar 28 13:45:07 2011
@@ -38,7 +38,9 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.cxf.attachment.AttachmentImpl;
+import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Endpoint;
@@ -463,7 +465,6 @@ public class DefaultCxfBinding implement
             }
         }
         
-        
         // propagate SOAP/protocol header list
         String key = Header.HEADER_LIST;
         Object value = cxfMessage.get(key);
@@ -474,7 +475,22 @@ public class DefaultCxfBinding implement
             } else {
                 ((List<?>)value).clear();
             }
-        }       
+        }
+        
+        // propagate the SOAPAction header
+        String soapAction = 
(String)camelHeaders.get(SoapBindingConstants.SOAP_ACTION);
+        // Remove SOAPAction from the protocol header, as it will not be 
overrided
+        if (ObjectHelper.isEmpty(soapAction) || "\"\"".equals(soapAction)) {
+            camelHeaders.remove(SoapBindingConstants.SOAP_ACTION);
+        }
+        soapAction = (String)cxfMessage.get(SoapBindingConstants.SOAP_ACTION);
+        if (soapAction != null) {
+            if 
(!headerFilterStrategy.applyFilterToExternalHeaders(SoapBindingConstants.SOAP_ACTION,
 soapAction, exchange)) {
+                camelHeaders.put(SoapBindingConstants.SOAP_ACTION, soapAction);
+                LOG.trace("Populate header from CXF header={} value={}", 
SoapBindingConstants.SOAP_ACTION, soapAction);
+            } 
+        }
+        
     }
     
     // replace the multi-part content-type

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java?rev=1086231&r1=1086230&r2=1086231&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyMessageModeNoSpringTest.java
 Mon Mar 28 13:45:07 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.cxf;
 
+import org.apache.camel.Exchange;
+
 public class CXFWsdlOnlyMessageModeNoSpringTest extends 
CXFWsdlOnlyPayloadModeNoSpringTest {
 
     @Override

Modified: 
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=1086231&r1=1086230&r2=1086231&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFWsdlOnlyPayloadModeNoSpringSoap12Test.java
 Mon Mar 28 13:45:07 2011
@@ -18,6 +18,7 @@ package org.apache.camel.component.cxf;
 
 import javax.xml.ws.Endpoint;
 
+import org.apache.camel.Exchange;
 import org.apache.camel.wsdl_first.PersonImpl12;
 import org.junit.BeforeClass;
 
@@ -34,4 +35,9 @@ public class CXFWsdlOnlyPayloadModeNoSpr
         return "{http://camel.apache.org/wsdl-first}PersonService12";;
     }
     
+    @Override
+    protected void checkSOAPAction(Exchange exchange) {
+        assertEquals(exchange.getIn().getHeader("SOAPAction"), 
"GetPersonAction");
+    }
+    
 }

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=1086231&r1=1086230&r2=1086231&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
 Mon Mar 28 13:45:07 2011
@@ -22,6 +22,8 @@ import javax.xml.namespace.QName;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.Holder;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.wsdl_first.Person;
@@ -58,12 +60,26 @@ public class CXFWsdlOnlyPayloadModeNoSpr
         }
 
     }
+    
+    protected void checkSOAPAction(Exchange exchange) {
+        // check the SOAPAction to be null
+        assertNull(exchange.getIn().getHeader("SOAPAction"));
+        
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
                 from("cxf://http://localhost:8092/PersonService?"; + 
PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + 
WSDL_URL_PROP + "&dataFormat=" + getDataFormat())
+                    .process(new Processor() {
+
+                        @Override
+                        public void process(Exchange exchange) throws 
Exception {
+                            checkSOAPAction(exchange);
+                        }
+                        
+                    })
                     .to("cxf://http://localhost:8093/PersonService?"; + 
PORT_NAME_PROP + "&" + SERVICE_NAME_PROP + getServiceName() + "&" + 
WSDL_URL_PROP + "&dataFormat=" + getDataFormat());
             }
         };

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java?rev=1086231&r1=1086230&r2=1086231&view=diff
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerProtocalHeaderTest.java
 Mon Mar 28 13:45:07 2011
@@ -41,6 +41,7 @@ public class CxfProducerProtocalHeaderTe
 
                     public void process(Exchange exchange) throws Exception {
                         assertNull("We should not get this header", 
exchange.getIn().getHeader("CamelCxfTest"));
+                        System.out.println("header " + 
exchange.getIn().getHeader("SOAPAction"));
                         assertNull("We should not get this header", 
exchange.getIn().getHeader("Transfer-Encoding"));
                        // check the headers
                         exchange.getOut().setHeader("Content-Type", 
"text/xml");
@@ -62,7 +63,8 @@ public class CxfProducerProtocalHeaderTe
                 exchange.getIn().setBody(params);
                 exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, 
"echo");
                 // Test the CxfHeaderFilterStrategy
-                exchange.getIn().setHeader("CamelCxfTest", "test");
+                exchange.getIn().setHeader("CamelCxfTest", "\"test\"");
+                exchange.getIn().setHeader("SOAPAction", "\"test\"");
                 exchange.getIn().setHeader("Transfer-Encoding", "chunked");
             }
         });


Reply via email to