Transforming from Java to XML with JAXB
Camel's JAXB Component is one of a number of components that can be used to convert your XML data back and forth from Java objects. It provides a Camel Data Format that allows you to use JAXB annotated Java classes, and then marshal (Java to XML) or unmarshal (XML to Java) your data.
JAXB is a Java standard for translating between XML data and Java that is used by creating annotated Java classes that bind, or map, to your XML data schema. The framework takes care of the rest.
This recipe will show you how to use the JAXB Camel Data Format to convert back and forth from Java to XML.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.transformation.jaxb
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with jaxb
.
To use Camel's JAXB Component, you need to add a dependency
element for the camel-jaxb
library, which provides the implementation for the JAXB Data Format.
Add the...