You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/09/14 17:27:31 UTC
svn commit: r1384820 - in /camel/branches/camel-2.9.x: ./
components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java
Author: davsclaus
Date: Fri Sep 14 15:27:30 2012
New Revision: 1384820
URL: http://svn.apache.org/viewvc?rev=1384820&view=rev
Log:
CAMEL-5615: Fixed camel-soap may marshal invalid XML with no tag name in the body.
Modified:
camel/branches/camel-2.9.x/ (props changed)
camel/branches/camel-2.9.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1384815
Merged /camel/branches/camel-2.10.x:r1384818
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.9.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.9.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java?rev=1384820&r1=1384819&r2=1384820&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java (original)
+++ camel/branches/camel-2.9.x/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/name/TypeNameStrategy.java Fri Sep 14 15:27:30 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) {