camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r881227 - /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
Date Tue, 17 Nov 2009 10:25:24 GMT
Author: davsclaus
Date: Tue Nov 17 10:25:22 2009
New Revision: 881227

URL: http://svn.apache.org/viewvc?rev=881227&view=rev
Log:
CAMEL-2183: Fixed cxfbean not working with GET. Willem Tam to review.

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java?rev=881227&r1=881226&r2=881227&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
Tue Nov 17 10:25:22 2009
@@ -36,7 +36,7 @@
         MessageImpl answer = new MessageImpl();
         org.apache.cxf.message.Exchange cxfExchange = exchange.getProperty(CxfConstants.CXF_EXCHANGE,
                                                                         org.apache.cxf.message.Exchange.class);
-        org.apache.camel.Message message = null;
+        org.apache.camel.Message message;
         if (isClient) {
             message = exchange.getOut();
         } else {
@@ -50,13 +50,14 @@
 
         CxfHeaderHelper.propagateCamelToCxf(headerFilterStrategy, message.getHeaders(), answer,
exchange);
 
-        InputStream body = null;
-        try {
-            body = message.getMandatoryBody(InputStream.class);
-        } catch (InvalidPayloadException e) {
-            throw new RuntimeCamelException(e);
+        // body can be empty in case of GET etc.
+        InputStream body = message.getBody(InputStream.class);
+        if (body != null) {
+            answer.setContent(InputStream.class, body);
+        } else if (message.getBody() != null) {
+            // fallback and set the body as what it is
+            answer.setContent(Object.class, body);
         }
-        answer.setContent(InputStream.class, body);
 
         answer.putAll(message.getHeaders());
         answer.setExchange(cxfExchange);
@@ -65,14 +66,15 @@
     }    
     
     public static org.apache.cxf.message.Message getCxfOutMessage(HeaderFilterStrategy headerFilterStrategy,
-            org.apache.camel.Exchange exchange, boolean isClient) {
+            org.apache.camel.Exchange exchange, boolean isClient) throws InvalidPayloadException
{
         org.apache.cxf.message.Exchange cxfExchange = exchange.getProperty(CxfConstants.CXF_EXCHANGE,
org.apache.cxf.message.Exchange.class);
         assert cxfExchange != null;
         org.apache.cxf.endpoint.Endpoint cxfEndpoint = cxfExchange.get(org.apache.cxf.endpoint.Endpoint.class);
         org.apache.cxf.message.Message outMessage = cxfEndpoint.getBinding().createMessage();
         outMessage.setExchange(cxfExchange);
         cxfExchange.setOutMessage(outMessage);
-        org.apache.camel.Message message = null;
+
+        org.apache.camel.Message message;
         if (isClient) {
             message = exchange.getIn();
         } else {
@@ -82,12 +84,7 @@
         CxfHeaderHelper.propagateCamelToCxf(headerFilterStrategy, message.getHeaders(), outMessage,
exchange);
 
         // send the body back
-        Source body = null;
-        try {
-            body = message.getMandatoryBody(Source.class);
-        } catch (InvalidPayloadException e) {
-            throw new RuntimeCamelException(e);
-        }
+        Source body = message.getMandatoryBody(Source.class);
         outMessage.setContent(Source.class, body);
         outMessage.putAll(message.getHeaders());
         return outMessage;



Mime
View raw message