Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x 75a3f0919 -> 1ddb0d34e


CAMEL-7471 Fixed the issue of SOAP with attachments for CXF_MESSAGE


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1ddb0d34
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1ddb0d34
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1ddb0d34

Branch: refs/heads/camel-2.12.x
Commit: 1ddb0d34e3124ec7deadd6ffbd8c393d359c5247
Parents: 75a3f09
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Thu May 29 21:25:11 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Thu May 29 21:28:53 2014 +0800

----------------------------------------------------------------------
 .../camel/component/cxf/DefaultCxfBinding.java    | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1ddb0d34/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
----------------------------------------------------------------------
diff --git 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
index ca1e6af..337bf89 100644
--- 
a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
+++ 
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
@@ -120,13 +120,19 @@ public class DefaultCxfBinding implements CxfBinding, 
HeaderFilterStrategyAware
         // propagate attachments
         Set<Attachment> attachments = null;
         boolean isXop = 
Boolean.valueOf(camelExchange.getProperty(Message.MTOM_ENABLED, String.class));
-        for (Map.Entry<String, DataHandler> entry : 
camelExchange.getIn().getAttachments().entrySet()) {
-            if (attachments == null) {
-                attachments = new HashSet<Attachment>();
+        DataFormat dataFormat = 
camelExchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY,  
+                                                          DataFormat.class);
+        // we should avoid adding the attachments if the data format is 
CXFMESSAGE, as the message stream 
+        // already has the attachment information
+        if (!DataFormat.CXF_MESSAGE.equals(dataFormat)) {
+            for (Map.Entry<String, DataHandler> entry : 
camelExchange.getIn().getAttachments().entrySet()) {
+                if (attachments == null) {
+                    attachments = new HashSet<Attachment>();
+                }
+                AttachmentImpl attachment = new AttachmentImpl(entry.getKey(), 
entry.getValue());
+                attachment.setXOP(isXop);
+                attachments.add(attachment);
             }
-            AttachmentImpl attachment = new AttachmentImpl(entry.getKey(), 
entry.getValue());
-            attachment.setXOP(isXop);
-            attachments.add(attachment);
         }
         
         if (attachments != null) {

Reply via email to