Running the File Output sample

After you have imported and deployed the sample, you can run it by following the instructions in Running the sample.

An example input test message and the corresponding output messages (one produced by the HTTPReply node, and one produced by the FileOutput node) are provided so that you can confirm that the sample has worked.

If you encounter any problems when you run the sample, see Resolving problems when running samples in the WebSphere Message Broker documentation.

Input test message

The test message that is used to run this sample is a SOAP message representing a sales invoice. The message is based on the following format:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:samp="http://www.samplemessage.broker.hursley.ibm.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<samp:SaleListMessage>
<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>
</samp:SaleListMessage>
</soap:Body>
</soap:Envelope>

Running the sample

This sample uses the message flow FileOutputNodeSampleFlow.

To run the sample:

  1. In the Broker Development view, expand the FileOutputNodeSampleFlowProject.
  2. Double-click FileOutputNodeSample_InputMessage.mbtest to open the message in the Test Client.
  3. Click Send message in the Detailed Properties panel, click Finish in the Deployment Location window (nothing is deployed at this time). A message is sent to the URL that is being listened to by the HTTPReply node. The URL is http://localhost:7080/FileOutputNodeSample. The message flow receives the SOAP message over HTTP and updates the description and price for the last item in the sales invoice. The message is written to a file, and a reply is sent back over HTTP.
  4. To check that the updated message has successfully been sent back over HTTP:
    1. View the reply message in the Detailed Properties panel, either by using the XML Structure viewer or the Source viewer.
    2. Compare this message with the expected output message from the HTTPReply node, that is detailed later in this topic.
  5. To check that the updated message has been output to a file in the specified directory:
    1. Go to the file system and look in the appropriate directory. For example:
      • On Windows, look in this directory: %MQSI_FILENODES_ROOT_DIRECTORY%\FileOutputNodeSample
      • On Linux, look in this directory: $MQSI_FILENODES_ROOT_DIRECTORY/FileOutputNodeSample
    2. Open the file, FileOutputNodeSample_OutputMessage.xml, in a text editor of your choice.
    3. Compare this file with the expected output message from the FileOutput node that is detailed later in this topic.

If all the preceding steps are successful, the sample is complete. Look at the nodes in the message flow FileOutputNodeSampleFlow to see how the results were achieved.

Expected output message from the HTTPReply node

The output message from the HTTPReply node is similar to the input message but has been updated in three ways:

  1. The first element <?xml version="1.0" encoding="UTF-8"?> has been removed from the message.
  2. The description and price of the last item has been updated. The description has been updated to "Deluxe Microscope" and the price has been updated to "44.00".
  3. The namespaced element <samp:SaleListMessage> has been replaced with <samp:SaleListReplyMessage>.

The following code shows the expected message, formatted with carriage returns to aid readability.

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:samp="http://www.samplemessage.broker.hursley.ibm.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<samp:SaleListReplyMessage>
<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>Deluxe Microscope</Description>
<Category>Miscellaneous</Category>
<Price>44.00</Price>
<Quantity>01</Quantity>
</Item>
<Balance>81.84</Balance>
<Currency>Euros</Currency>
</Invoice>
</SaleList>
<Trailer>
<CompletionTime>12.00.00</CompletionTime>
</Trailer>
</SaleEnvelope>
</samp:SaleListReplyMessage>
</soap:Body>
</soap:Envelope>

Expected output message from the FileOutput node

The output message from the FileOutput node is similar to the input message but has been updated in three ways:

  1. The SOAP envelope has been removed from the message.
  2. The description and price of the last item has been updated. The description has been updated to "Deluxe Microscope" and the price has been updated to "44.00".
  3. The namespaced element <samp:SaleListMessage> has been replaced with <NS1:SaleListReplyMessage xmlns:NS1="http://www.samplemessage.broker.hursley.ibm.com">.

The following code shows the expected message, formatted with carriage returns to aid readability.

<?xml version="1.0" encoding="UTF-8"?>
<NS1:SaleListReplyMessage xmlns:NS1="http://www.samplemessage.broker.hursley.ibm.com">
<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>Deluxe Microscope</Description>
<Category>Miscellaneous</Category>
<Price>44.00</Price>
<Quantity>01</Quantity>
</Item>
<Balance>81.84</Balance>
<Currency>Euros</Currency>
</Invoice>
</SaleList>
<Trailer>
<CompletionTime>12.00.00</CompletionTime>
</Trailer>
</SaleEnvelope>
</NS1:SaleListReplyMessage>

Back to sample home