[
https://issues.apache.org/jira/browse/CAMEL-9066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bob Blackard updated CAMEL-9066:
--------------------------------
Comment: was deleted
(was: I tried to create unit tests based on my example, but they're not
behaving the same. I'm attaching the "patch", but be warned that for reasons I
don't understand yet the unmarshal is producing a Body of type
com.sun.org.apache.xerces.internal.dom.ElementNSImp rather than
com.example.contact.Contact. The log for the three new tests shows:
2015-08-10 14:38:47,582 [main ] INFO Tracer
- ID-blackard-vm-50620-1439231926880-0-2 >>> (route1) from(direct://start) -->
unmarshal[org.apache.camel.dataformat.soap.SoapJaxbDataFormat@3c643130] <<<
Pattern:InOnly, Headers:{breadcrumbId=ID-blackard-vm-50620-1439231926880-0-1},
BodyType:java.io.BufferedInputStream, Body:[Body is instance of
java.io.InputStream]
2015-08-10 14:38:47,865 [main ] INFO Tracer
- ID-blackard-vm-50620-1439231926880-0-2 >>> (route1)
unmarshal[org.apache.camel.dataformat.soap.SoapJaxbDataFormat@3c643130] -->
marshal[org.apache.camel.dataformat.soap.SoapJaxbDataFormat@3c643130] <<<
Pattern:InOnly, Headers:{breadcrumbId=ID-blackard-vm-50620-1439231926880-0-1,
org.apache.camel.dataformat.soap.UNMARSHALLED_HEADER_LIST=[com.example.soapheaders.Comment@770d8fe9]},
BodyType:com.sun.org.apache.xerces.internal.dom.ElementNSImpl,
Body:<cont:Contact xmlns:cont="http://www.example.com/contact"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><name>Smith</name><numOrders>0</numOrders><revenue>100000.0</revenue>
</cont:Contact>
2015-08-10 14:38:47,865 [main ] ERROR DefaultErrorHandler
- Failed delivery for (MessageId: ID-blackard-vm-50620-1439231926880-0-1 on
ExchangeId: ID-blackard-vm-50620-1439231926880-0-2). Exhausted after delivery
attempt: 1 caught: java.lang.RuntimeException: The type
com.sun.org.apache.xerces.internal.dom.ElementNSImpl needs to have an XmlType
annotation with name
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor
Elapsed (ms)
[route1 ] [route1 ] [direct://start
] [ 283]
[route1 ] [unmarshal1 ]
[unmarshal[org.apache.camel.model.DataFormatDefinition@79f361e5]
] [ 236]
[route1 ] [marshal1 ]
[marshal[org.apache.camel.model.DataFormatDefinition@59a03fef]
] [ 47]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[###REPLACE_ME### Id
ID-blackard-vm-50620-1439231926880-0-2###REPLACE_ME### ExchangePattern
InOnly###REPLACE_ME### Headers
{breadcrumbId=ID-blackard-vm-50620-1439231926880-0-1, CamelRedelivered=false,
CamelRedeliveryCounter=0,
org.apache.camel.dataformat.soap.UNMARSHALLED_HEADER_LIST=[com.example.soapheaders.Comment@770d8fe9]}###REPLACE_ME###
BodyType
com.sun.org.apache.xerces.internal.dom.ElementNSImpl###REPLACE_ME###
Body <cont:Contact xmlns:cont="http://www.example.com/contact"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><name>Smith</name><numOrders>0</numOrders><revenue>100000.0</revenue>
</cont:Contact>]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.RuntimeException: The type
com.sun.org.apache.xerces.internal.dom.ElementNSImpl needs to have an XmlType
annotation with name
at
org.apache.camel.dataformat.soap.name.TypeNameStrategy.findQNameForSoapActionOrType(TypeNameStrategy.java:39)
)
> Include any headers unmarshalled by SoapJaxbDataFormat in content marshalled
> by the same.
> -----------------------------------------------------------------------------------------
>
> Key: CAMEL-9066
> URL: https://issues.apache.org/jira/browse/CAMEL-9066
> Project: Camel
> Issue Type: Improvement
> Components: camel-soap
> Affects Versions: 2.12.5, 2.16.0, 2.15.3, 2.14.4, Future, 2.16
> Environment: Any
> Reporter: Bob Blackard
> Assignee: Willem Jiang
> Labels: patch
> Fix For: 2.16.0, 2.15.3, 2.14.4, Future, 2.16
>
> Attachments: camel.patch, soapjaxb-header-marshal-example.zip
>
>
> The current implementation of the Soap11DataFormatAdapter and
> Soap12DataFormatAdapter will never generate SOAP Headers when a JAXB object
> is the inputObject.
> If the unmarshal is done with ignoreUnmarshalledHeaders set to false, then
> the SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST message header is
> populated with a list of Objects or JAXBElement<?>s. However, during the
> doMarshal, this message header is never referenced. Therefore, the sequence:
> from("direct:source").unmarshal(fromSoapDataFormat).process(doSomething).marshal(toSoapDataFormat).to("mock:end");
> will never produce SOAP Headers in the outbound document.
> The doUnmarshal passes the inputObject and an empty List<JAXBElement<?>> into
> createContentFromObject. However, is the inputObject is an ordinary JAXB
> object (or JAXBElement<?>) then no header content will be created, and since
> the Exchange isn't sent to createContentFromObject, the
> SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST cannot be referenced.
> It seems to me that, if ignoreUnmarshalledHeaders is false, and the
> SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST is non-empty, and in the
> event the inbound Exchange does not contain an Exception, then the contents
> of the SoapJaxbDataFormat.SOAP_UNMARSHALLED_HEADER_LIST should be added to
> the headerContent before the call to createContentFromObject.
> I have checked the code for SoapJaxbDataFormat, Soap11DataFormatAdapter and
> Soap12DataFormatAdapter from camel-soap 2.12.0 through 2.15.2 and it looks
> like these three classes haven't changed.
> I crated a demo project and patch, originally against JBoss Fuse 6.1.0, but
> offer it here for the camel-soap 2.12.x branch. I have also applied and
> tested the patch against camel-soap in the master branch (2.16-SNAPSHOT).
> Indeed, it looks like this patch can be applied from any point 2.12 and
> forward.
> The demo can be run against 2.12.5 (or any released version - just change the
> camel.version property in the POM) to demonstrate what I think is the
> failure. It can also be run against a patched 2.12.6-SNAPSHOT or
> 2.16-SNAPSHOT (again, just play around with the camel.version property) to
> demonstrate what I think is correct behavior.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)