After you have imported and deployed the sample, you can run it by following the instructions in the Running the sample section.
If you encounter any problems when you run the sample, see Resolving problems when running samples in the WebSphere Message Broker documentation.
This topic also includes an example input test message and a corresponding output message so that you can confirm that the sample has worked.
All the test messages that are used to run this sample are based on the following format:
<SaleEnvelope>
<Header>
<SaleListCount>1</SaleListCount>
</Header>
<SaleList>
<Invoice>
<Initial>K</Initial>
<Initial>A</Initial>
<Surname>Braithwaite</Surname>
<Item>
<Code>00</Code>
<Code>01</Code>
<Code>02</Code>
<Description>Twister</Description>
<Category>Games</Category>
<Price>00.30</Price>
<Quantity>01</Quantity>
</Item>
<Item>
<Code>02</Code>
<Code>03</Code>
<Code>01</Code>
<Description>The Times Newspaper</Description>
<Category>Books and Media</Category>
<Price>00.20</Price>
<Quantity>01</Quantity>
</Item>
<Balance>00.50</Balance>
<Currency>Sterling</Currency>
</Invoice>
<Invoice>
<Initial>T</Initial>
<Initial>J</Initial>
<Surname>Dunnwin</Surname>
<Item>
<Code>04</Code>
<Code>05</Code>
<Code>01</Code>
<Description>The Origin of Species</Description>
<Category>Books and Media</Category>
<Price>22.34</Price>
<Quantity>02</Quantity>
</Item>
<Item>
<Code>06</Code>
<Code>07</Code>
<Code>01</Code>
<Description>Microscope</Description>
<Category>Miscellaneous</Category>
<Price>36.20</Price>
<Quantity>01</Quantity>
</Item>
<Balance>81.84</Balance>
<Currency>Euros</Currency>
</Invoice>
</SaleList>
<Trailer>
<CompletionTime>12.00.00</CompletionTime>
</Trailer>
</SaleEnvelope>
This sample contains two JavaCompute nodes, one of which uses XPath expressions (JavaComputeTransformXPath), and one of which uses the Java Plug-in Node API (JavaComputeTransformNoXPath). This sample provides a comparison between the two different approaches, both of which achieve the same result.
The following instructions cover the JavaComputeTransformXPath node - for the JavaComputeTransformNoXPath node, follow the instructions in exactly the same way but replace XPath with NoXPath where appropriate.
This sample uses the message flow JavaComputeTransformXPathFlow. It contains one input queue called JAVACOMPUTE.TRANSFORMXPATH.IN. The message flow can transform and route the message to one of two output queues (JAVACOMPUTE.TRANSFORMXPATH.OUT and JAVACOMPUTE.TRANSFORMXPATH.FAILURE).
To run the sample:
If all the preceding steps are successful, the sample is complete. Look at the Java code in the message flow JavaComputeTransformXPathFlow to see how the message transformation was achieved.
Regardless of which of the two message flows you use, the following example shows how the output message is formatted:
<SaleEnvelope>
<SaleList>
<Statement Type="Monthly" Style="Full">
<Customer>
<Initials>KA</Initials>
<Name>Braithwaite</Name>
<Balance>00.50</Balance>
</Customer>
<Purchases>
<Article>
<Desc>Twister</Desc>
<Cost>0.48</Cost>
<Qty>01</Qty>
</Article>
<Article>
<Desc>The Times Newspaper</Desc>
<Cost>0.32</Cost>
<Qty>01</Qty>
</Article>
</Purchases>
<Amount>0.8</Amount>
</Statement>
<Statement Type="Monthly" Style="Full">
<Customer>
<Initials>TJ</Initials>
<Name>Dunnwin</Name>
<Balance>81.84</Balance>
</Customer>
<Purchases>
<Article>
<Desc>The Origin of Species</Desc>
<Cost>35.744</Cost>
<Qty>02</Qty>
</Article>
<Article>
<Desc>Microscope</Desc>
<Cost>57.92</Cost>
<Qty>01</Qty>
</Article>
</Purchases>
<Amount>129.408</Amount>
</Statement>
</SaleList>
</SaleEnvelope>