concept xml message in category esb

This is an excerpt from Manning's book Open-Source ESBs in Action: Example Implementations in Mule and ServiceMix.
In the example shown in figure 2.2, a comma-separated values (CSV) message is read from an FTP server, transformed into an XML message, and then sent to the payment service. After the payment service finishes processing the message, the message is again transformed to CSV and dropped on the file system.
In the JiBX mapping file you define the root element name of the XML message (person in this case) and the Java class we want to map it to
. Notice that there is a binding root element
, which is used by JiBX to represent the start of the mapping definitions. The next part involves defining the mapping between the message child elements and the properties of the Java class
. We do this by specifying the name of the XML element (e.g., firstname), and then in the field property we can specify the corresponding Java property (e.g., firstName). Figure 3.2 shows the mapping of a value from an XML file to a property in a Java object.
For ServiceMix we need to provide a helper class to implement the transformations. ServiceMix itself is JBI based, so all the data that’s sent between the components needs to be in line with the JBI specification—which means it has to be XML. So when we create our custom components for ServiceMix, we can use a helper class that handles the transformation for us. Let’s look at the servicemix-bean implementation that uses JiBX to marshal and unmarshal the XML messages (listing 3.12).
The SimpleListenerBean implementation contains the onMessageExchange method of the MessageExchangeListener interface
. The incoming message of the JBI message exchange is unmarshaled to a Person Java object, using a JiBX utility class that we discuss in listing 3.13. Then the name of the person is changed on the Java object and the object is marshaled to an XML message again. The XML message is a Source instance; in this example we use a StreamSource.
. Notice that there is a binding root element
, which is used by JiBX to represent the start of the mapping definitions. The next part involves defining the mapping between the message child elements and the properties of the Java class
. We do this by specifying the name of the XML element (e.g., firstname), and then in the field property we can specify the corresponding Java property (e.g., firstName).