Database Reference
In-Depth Information
Our MessageHeader elements will be used in the next step for the recognition of busi-
ness process and extraction of the execution plan for this process. It will be used further
for the construction of the XML Message Header in the delivery phase. Here, we will dis-
cuss how we are going to implement marshalling/unmarshalling for the core objects that
we have in our broker. You can see a list of objects in the preceding screenshot.
Naturally, not all of them have to be converted into XML and back, but Process , Pro-
cessHeader , Acknowledge , and MessageHeader are the primary candidates. For in-
stance, in Chapter 2 , An Introduction to Oracle Fusion - a Solid Foundation for Service
Inventory , dedicated to modern SOA technology, we mentioned several common O/X
mappers such as JAXB and JiBX frameworks. The key factors that are naturally defining
our choice of marshaller are performance and ease of configuration. Spring O/X can be a
very good alternative as we do not need to construct the JAXB context, JiBX binding
factories, and so on. We have other options such as using Castor XML mappings,
XMLBeans marshallers, and XStreams. The choice is yours, but you can also implement
the conversion of an object to XML without any libraries. Here, our task is really simple.
Therefore, good, simple Java constructs will work quite well and surprisingly fast. Every
object has its own helper, where we have a primitive section for XML construction. First,
we get an instance of the element writer utility, based on System.out.println() , as
shown in the following code:
ElementWriter ewriter = new ElementWriter();
java.io.StringWriter xdiDocWriter = new
java.io.StringWriter();
We will then write our elements as shown in the following code:
xdiDocWriter.write("<mhs:MessageHeader>");
ewriter.element(xdiDocWriter, "mhs:XDIMsgId",
mhs.getXDIMsgId());
ewriter.element(xdiDocWriter, "mhs:BusinessEvent",
mhs.getBusinessEvent());
ewriter.element(xdiDocWriter, "mhs:Sender",
mhs.getSender());
For more complex objects and messages, we will advise you to use the Spring framework,
or any other that suits you.
Search WWH ::




Custom Search