elwis
elwis

Reputation: 1405

Mule Jaxb to object transforms to wrong object

I have an integration with some flows and JAXBcontext declared like this

<mulexml:jaxb-context name="JaxbContext" packageNames="se.razorlib.SystemAProduct:se.razorlib.SystemAPurchase:se.razorlib.SystemAOrder"/>

In one of my flows I transform XML to Purchase and in another XML to Order, which are very similar objects. However, in the Order flow JAXB transforms my XML to PurchaseObject instead of OrderObject, which of course throws me an error:

The object transformed is of type: "SimpleDataType{type=se.razorlib.SystemAPurchase.Header, mimeType='*/*', encoding='null'}", but the expected return type is "SimpleDataType{type=se.razorlib.SystemAOrder.Header, mimeType='*/*', encoding='null'}"

This is my configuration, how can I force a tranfsformation to the "right" object?

<file:inbound-endpoint path="C:\temp\OrderfileIn" responseTimeout="10000" doc:name="FileIn"/>
<mulexml:jaxb-xml-to-object-transformer jaxbContext-ref="JAXB_Context" doc:name="XML to JAXB Object" returnClass="se.razorlib.SystemAOrder.Header"/>    
<custom-transformer returnClass="se.razorlib.SystemBOrder.SalesOrder" encoding="UTF-8" class="se.didriksson.Transformer.Map2SystemBOrder" doc:name="Map2B"/>

Upvotes: 0

Views: 79

Answers (1)

asela38
asela38

Reputation: 4644

To pick the correct bean class you have to place the

@XmlRootElement(name = "Order") 

Instead of order you may have to put the root element of your xml.

Another point I also face an issue with mule 3.7 which is it doesn't read package.info file in the package

Upvotes: 1

Related Questions