This section describes how to transform messages using the features provided in XML configuration.
You can convert between low-level and high-level message formats using the following elements:
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 the following data formats:
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. For example, to
read a serialized Java object from an endpoint, SourceURL
,
and convert it to a Java object, you can use the following rule:
<camelContext id="serialization" xmlns="http://activemq.apache.org/camel/schema/spring"> <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, as follows:
<camelContext id="jaxb" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="SourceURL
"/> <unmarshal> <jaxb prettyPrint="true" contextPath="GeneratedPackageName
"/> </unmarshal> <to uri="TargetURL
"/> </route> </camelContext>
Where GeneratedPackagename
is 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. For example, to unmarshal XML data to a Java object using XMLBeans, define a rule like the following:
<camelContext id="xmlBeans" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="SourceURL
"/> <unmarshal> <xmlBeans prettyPrint="true"/> </unmarshal> <to uri="TargetURL
"/> </route> </camelContext>
XStream — Is currently not supported in XML configuration.
Artix Data Services —FUSE Mediation Router also integrates with Artix Data Services, enabling you to integrate stub code generated by Artix Data Services. See Artix Data Services for details.
Artix Data Services is a powerful tool for converting documents and messages between
different data formats. In Artix Data Services, you can use a graphical tool to define
complex mapping rules (including processing of data content) and then generate stub code to
implement the mapping rules. See Progress
Artix Data Services home page and the Artix Data
Services documentation for more details. The marshal
and
unmarshal
elements are capable of consuming Artix Data Services stub
code to perform transformations on message formats. Example 3.4 shows
a rule that unmarshals XML documents into a canonical format (Java objects) and then
marshals the canonical format into the tag/value pair format.
Example 3.4. Using Artix Data Services to Marshal and Unmarshal
<camelContext id="artixDS" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="SourceURL
"/> <unmarshal> <artixDS contentType="Xml" elementTypeName="iso.std.iso.x20022.tech.xsd.pacs.x008.x001.x01.DocumentElement"/> </unmarshal> <marshal> <artixDS contentType="TagValuePair"/> </marshal> <to uri="TargetURL
"/> </route> </camelContext>
Where the contentType
attribute can be set to one of the following
values: TagValuePair
, Sax
, Xml
,
Java
, Text
, Binary
,
Auto
, Default
.
![]() | Note |
---|---|
Artix Data Services is licensed separately from FUSE Mediation Router. |