camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1384818 - in /camel/branches/camel-2.10.x: ./ components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java
Date Fri, 14 Sep 2012 15:24:03 GMT
Author: davsclaus
Date: Fri Sep 14 15:24:03 2012
New Revision: 1384818

URL: http://svn.apache.org/viewvc?rev=1384818&view=rev
Log:
CAMEL-5615: Fixed camel-soap may marshal invalid XML with no tag name in the body.

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1384815

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java?rev=1384818&r1=1384817&r2=1384818&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java
Fri Sep 14 15:24:03 2012
@@ -16,10 +16,13 @@
  */
 package org.apache.camel.dataformat.soap.name;
 
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSchema;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.namespace.QName;
 
+import org.apache.camel.util.ObjectHelper;
+
 /**
  * Strategy to determine the marshalled element name by looking at the
  * annotations of the class to be marshalled
@@ -42,7 +45,15 @@ public class TypeNameStrategy implements
                 nameSpace = xmlSchema.namespace();
             }
         }
-        return new QName(nameSpace, xmlType.name());
+        // prefer name from the XmlType, and fallback to XmlRootElement
+        String localName = xmlType.name();
+        if (ObjectHelper.isEmpty(localName)) {
+            XmlRootElement root = type.getAnnotation(XmlRootElement.class);
+            if (root != null) {
+                localName = root.name();
+            }
+        }
+        return new QName(nameSpace, localName);
     }
 
     public Class<? extends Exception> findExceptionForFaultName(QName faultName) {



Mime
View raw message