Does your generated jaxb class contains a XmlRootElement annotation?
I think that we had to include is via xml binding to the generated classes to
get it work.
<jaxb:bindings node="//xs:complexType[@name=execution]">
<annox:annotate>
<annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
name="execution"/>
</annox:annotate>
</jaxb:bindings>
Rgds,
Jörg
-----Original Message-----
From: Alex Soto <[email protected]>
Sent: Dienstag, 28. August 2018 17:20
To: [email protected]
Subject: Rest DSL XML Binding SAX Parse Exception
My Rest Service fails to parse the input XML with error:
SAXParseException2; lineNumber: 2; columnNumber: 1; unexpected element
(uri:”http://tempuri.org", local:"execution"). Expected elements are (none)]
<restConfiguration
component="servlet"
bindingMode="xml"
contextPath="{{context.path}}{{api.root.path}}"
port="{{port}}"
enableCORS="false">
<componentProperty key="matchOnUriPrefix" value="true"/>
<endpointProperty key="servletName" value=“restApiServlet"/>
<endpointProperty key="headerFilterStrategy"
value="#headerFilter" />
<dataFormatProperty key="contentTypeHeader" value="false" />
<dataFormatProperty key="objectFactory" value="true" />
<dataFormatProperty key="contextPath" value="org.test.schema"/>
</restConfiguration>
<post type=“org.test.schema.Execution"
outType="org.test.schema.ExecutionResource">
<to uri="direct:create-execution"/>
</post>
The client is posting this payload:
<ns2:execution xmlns:ns2="http://tempuri.org" >
<ns2:scheduledFor>2018-08-29T10:35:55.577-04:00</ns2:scheduledFor>
<ns2:query>cXVlcnkgYnl0ZXM=</ns2:query>
</ns2:execution>
The jaxb classes in package org.test.schema are generated with
maven-jaxb2-plugin, so the package contains ObjectFactory and all proper
annotations.
What else does Camel need to properly bind the XML to the Java class?
Why is it not parsing the XML correctly?
Best regards,
Alex soto