camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r772053 - in /camel/branches/camel-1.x/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/CxfBinding.java test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
Date Wed, 06 May 2009 04:54:39 GMT
Author: ningjiang
Date: Wed May  6 04:54:38 2009
New Revision: 772053

URL: http://svn.apache.org/viewvc?rev=772053&view=rev
Log:
CAMEL-1586 make sure we don't lost the content-type from the producer of Cxf endpoint

Modified:
    camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
    camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java

Modified: camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java?rev=772053&r1=772052&r2=772053&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
(original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfBinding.java
Wed May  6 04:54:38 2009
@@ -195,8 +195,11 @@
         if (context != null) {
             MessageContext messageContext = new WrappedMessageContext(context, null, Scope.HANDLER);
             response.put(Client.RESPONSE_CONTEXT, messageContext);
-            //put the ResponseCode in the response context
-            Object value = context.get(Message.RESPONSE_CODE);
+            //put the protocol headers into the message headers
+            Map<String, List<String>> protocolHeaders =
+                CastUtils.cast((Map)messageContext.get(Message.PROTOCOL_HEADERS));
+            response.put(Message.PROTOCOL_HEADERS, protocolHeaders);            
+            Object value = context.get(Message.RESPONSE_CODE);            
             if (value != null) {
                 response.put(Message.RESPONSE_CODE, value);
             }

Modified: camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java?rev=772053&r1=772052&r2=772053&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
Wed May  6 04:54:38 2009
@@ -18,6 +18,8 @@
 
 import java.util.Map;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.cxf.jaxws.context.WrappedMessageContext;
@@ -44,4 +46,21 @@
         assertEquals("Should get the content type", protocalHeaders.get("content-type").toString(),
"[text/xml; charset=utf-8]");
         assertEquals("Should get the response code ", context.get("org.apache.cxf.message.Message.RESPONSE_CODE"),
200);
     }
+    
+    public void testTheContentTypeOnTheWire() throws Exception {
+        Exchange exchange = template.send(ROUTER_ADDRESS,  new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"

+                                         + "<soap:Body><ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
+                                         + "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">hello
world</arg0>"
+                                         + "</ns1:echo></soap:Body></soap:Envelope>");
+            }
+
+        });        
+        assertNotNull("We should get the content type here", exchange.getOut().getHeader("content-type"));
+        assertEquals("Get wrong content type", "text/xml; charset=utf-8", exchange.getOut().getHeader("content-type"));
+        String response = exchange.getOut().getBody(String.class);        
+        assertNotNull("Response should not be null", response);
+        assertTrue("We should get right return result", response.indexOf("echo hello world")
> 0);
+    }
 }



Mime
View raw message