Nav
You are viewing an older version of this topic. To go to a different version, use the version menu at the upper-right. +

JAXB Transformers

The JAXB transformers allow objects to be serialized to XML and back again using the JAXB binding framework. To configure a transformer that will convert XML to a Person object use 


         
      
1
<mulexml:jaxb-xml-to-object-transformer name="XmlToPerson" jaxbContext-ref="myJaxb" returnClass="org.mule.jaxb.model.Person"/>

You can then reference this transformer from an endpoint:


         
      
1
<jms:inbound-endpoint queue="another.queue" transformer-refs="XmlToPerson" />

The returnClass is a common transformer attribute and defines that this transformer will create a Person object.

Note that we have a reference to a JAXBContext via the jaxbContext-ref attribute, you can create this context object in your configuration file.


         
      
1
<mulexml:jaxb-context name="myJaxb" packageNames="org.mule.jaxb.model"/>
You can always use Spring to create objects as well. To create the JAXBContext using spring you could add the following to your Mule XML configuration too.

The opposite transformer would allow you to convert from a Person object to XML -


         
      
1
<mulexml:jaxb-object-to-xml-transformer name="PersonToXml" jaxbContext-ref="myJaxb"/>

JAXB Bindings

Mule offers automatic JAXB Bindings so you don’t even need use these transformers for most scenarios.

In this topic:

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+