Author: ningjiang
Date: Fri Oct 21 09:01:39 2011
New Revision: 1187222

URL: http://svn.apache.org/viewvc?rev=1187222&view=rev
Log:
CAMEL-4570 DefaultCxfBinding should take consideration of the 
Exchange.HTTP_RESPONSE_CODE

Added:
    
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageCamelHttpRouterTest.java
   (with props)
    
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml
   (with props)
Modified:
    
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.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=1187222&r1=1187221&r2=1187222&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
 Fri Oct 21 09:01:39 2011
@@ -547,20 +547,21 @@ public class DefaultCxfBinding implement
             transportHeaders.putAll(headers);
         }
             
-        for (Map.Entry<String, Object> entry : camelHeaders.entrySet()) {    
-            // this header should be filtered, continue to the next header
-            if (headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(), 
entry.getValue(), camelExchange)) {
+        for (Map.Entry<String, Object> entry : camelHeaders.entrySet()) {
+            // put response code in request context so it will be copied to 
CXF message's property
+            if (Message.RESPONSE_CODE.equals(entry.getKey()) || 
Exchange.HTTP_RESPONSE_CODE.equals(entry.getKey())) {
+                LOG.debug("Propagate to CXF header: {} value: {}", 
Message.RESPONSE_CODE, entry.getValue());
+                cxfContext.put(Message.RESPONSE_CODE, entry.getValue());
                 continue;
             }
             
-            LOG.trace("Propagate to CXF header: {} value: {}", entry.getKey(), 
entry.getValue());
-            
-            // put response code in request context so it will be copied to 
CXF message's property
-            if (Message.RESPONSE_CODE.equals(entry.getKey())) {
-                cxfContext.put(entry.getKey(), entry.getValue());
+            // this header should be filtered, continue to the next header
+            if (headerFilterStrategy.applyFilterToCamelHeaders(entry.getKey(), 
entry.getValue(), camelExchange)) {
                 continue;
             }
             
+            LOG.debug("Propagate to CXF header: {} value: {}", entry.getKey(), 
entry.getValue());
+            
             // put SOAP/protocol header list in exchange
             if (Header.HEADER_LIST.equals(entry.getKey())) {
                 List<Header> headerList = (List<Header>)entry.getValue();

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageCamelHttpRouterTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageCamelHttpRouterTest.java?rev=1187222&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageCamelHttpRouterTest.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfGreeterMessageCamelHttpRouterTest.java
 Fri Oct 21 09:01:39 2011
@@ -0,0 +1,63 @@
+/**
+ * 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.builder.RouteBuilder;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfGreeterMessageCamelHttpRouterTest extends 
CxfGreeterMessageRouterTest {
+    protected static Endpoint endpoint;
+    protected static String serverAddress = "http://localhost:"; + getPort1() 
+        + "/CxfGreeterMessageCamelHttpRouterTest/SoapContext/SoapPort";
+    @AfterClass
+    public static void stopService() {
+        if (endpoint != null) {
+            endpoint.stop();
+        }
+    }
+
+
+    @BeforeClass
+    public static void startService() {
+        Object implementor = new GreeterImpl();
+        String address = "http://localhost:"; + getPort1() 
+            + "/CxfGreeterMessageCamelHttpRouterTest/SoapContext/SoapPort";
+        endpoint = Endpoint.publish(address, implementor); 
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                
from("cxf:bean:routerEndpoint?dataFormat=Message&publishedEndpointUrl=http://www.simple.com/services/test";)
+                    .to(serverAddress + "?throwExceptionOnFailure=false");
+            }
+        };
+    }
+    
+    @Override
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml");
+    }
+
+}

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

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

Added: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml?rev=1187222&view=auto
==============================================================================
--- 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml
 Fri Oct 21 09:01:39 2011
@@ -0,0 +1,38 @@
+<?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:cxf="http://camel.apache.org/schema/cxf";
+
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/cxf 
http://camel.apache.org/schema/cxf/camel-cxf.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+   <import resource="classpath:META-INF/cxf/cxf.xml"/>
+   <!-- Added the import for testing the CAMEL-329 -->
+
+
+   <cxf:cxfEndpoint id="routerEndpoint" 
address="http://localhost:${CXFTestSupport.port2}/CxfGreeterMessageCamelHttpRouterTest/CamelContext/RouterPort";
+               serviceClass="org.apache.hello_world_soap_http.GreeterImpl"/>
+  
+
+</beans>
\ No newline at end of file

Propchange: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/GreeterEndpointWithCamelHttpBeans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to