You can convert between low-level and high-level message formats using the following patterns:
marshal— Converts a high-level data format to a low-level data format.unmarshal— Converts a low-level data format to a high-level data format.
Fuse Mediation Router supports marshalling and unmarshalling of a number of data formats including:
Java serialization—Enables you to convert a Java object to a blob of binary data. For this data format, unmarshalling converts a binary blob to a Java object, and marshalling converts a Java object to a binary blob. To read a serialized Java object from an endpoint,
SourceURL, and convert it to a Java object, you use a rule like the one shown in Example 7.2.Example 7.2. Unmarshalling from Java
<camelContext id="serialization"> <route> <from uri="
SourceURL"/> <unmarshal> <serialization/> </unmarshal> <to uri="TargetURL"/> </route> </camelContext>JAXB—Provides a mapping between XML schema types and Java types (see https://jaxb.dev.java.net/). For JAXB, unmarshalling converts an XML data type to a Java object, and marshalling converts a Java object to an XML data type. Before you can use JAXB data formats, you must compile your XML schema using a JAXB compiler to generate the Java classes that represent the XML data types in the schema. This is called binding the schema. After the schema is bound, you define a rule to unmarshal XML data to a Java object, using code like Example 7.3.
Example 7.3. Unmarshalling JAXB data
<camelContext id="jaxb"> <route> <from uri="
SourceURL"/> <unmarshal> <jaxb prettyPrint="true" contextPath="GeneratedPackageName"/> </unmarshal> <to uri="TargetURL"/> </route> </camelContext>GeneratedPackagenameis the name of the Java package generated by the JAXB compiler, which contains the Java classes representing your XML schema.XMLBeans—Provides an alternative mapping between XML schema types and Java types (see http://xmlbeans.apache.org/). For XMLBeans, unmarshalling converts an XML data type to a Java object and marshalling converts a Java object to an XML data type. To unmarshal XML data to a Java object using XMLBeans, you use code like the Example 7.4.
Example 7.4. Unmarshalling from XMLBeans
<camelContext id="xmlBeans"> <route> <from uri="
SourceURL"/> <unmarshal> <xmlBeans prettyPrint="true"/> </unmarshal> <to uri="TargetURL"/> </route> </camelContext>








