Running the File Output sample

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

This topic also includes an example input test message and corresponding output messages (one produced by the HTTPReply node, and one produced by the FileOutput node), so that you can confirm that the sample has worked.

Input test message

The test message used in running this sample is a SOAP message representing a sales invoice. It 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 Message Brokers Toolkit, switch to the Broker Application Development perspective.
  2. In the Broker Development view, expand the FileOutputNodeSampleFlowProject.
  3. Double click FileOutputNodeSample_InputMessage.mbtest to open the message in the Test Client.
  4. Click Send message in the Detailed Properties panel, then Finish in the Deployment Location pop-up (nothing is deployed at this time). A message is sent to the URL 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. Then the message is written to a file, and a reply is sent back over HTTP.
  5. To check that the updated message has successfully been sent back over HTTP:
    1. View the reply message in the Detailed Properties panel, either using the XML Structure viewer or the Source viewer.
    2. Compare this with the expected output message, from the HTTPReply node, that is detailed below.
  6. 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: C:\Documents and Settings\All Users\Application Data\IBM\MQSI\file\FileOutputNodeSample
      On Linux®, look in this directory: /var/mqsi/file/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 below.

If all the steps above are successful, then the sample is complete. Take a 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 expected message is shown below, 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 expected message is shown below, 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