Running the sample to change a namespace

The message flow in this example demonstrates how to change a namespace in a message. The input message contains one or more elements that use a namespace. These elements might use one or more different namespaces.

Use the instructions in this topic to run the sample. These instructions include an example of an input test message and the corresponding expected output message. Use the expected output message to 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 you use to run this sample is based on the following format:

<?xml version="1.0" encoding="UTF-8"?>
    <samp:SaleListMessage
  	xmlns:samp="http://www.samplemessage.broker.hursley.ibm.com"
  	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.samplemessage.broker.hursley.ibm.com/SampleMessageNamespace1.xsd">
	 <SaleEnvelope>
		 <Header>
		  <SaleListCount>1</SaleListCount>
		 </Header>
	 <SaleList>
	  <Invoice>
	   <Initial>K</Initial>
	   <Initial>A</Initial>
	   <Surname>Braithwaite</Surname>
	   <Item>
		...
	   </Item>
	   <Balance>81.84</Balance>
	   <Currency>EUR</Currency>
	  </Invoice>
	</SaleList>
 	<Trailer>
	  <CompletionTime>2000-01-01 00:00:01.000000</CompletionTime>
	</Trailer>
  </SaleEnvelope>
</samp:SaleListMessage>

Running the sample

This sample uses the message flow called CHANGENAMESPACEMF.

To run the sample:

  1. In the Broker Development view, expand the CHANGENAMESPACEMF Message Broker project.
  2. Double-click CHANGENAMESPACEMF.mbtest to open the file in the Test Client.
  3. Click Send Message. A message is sent to the CHANGENAMESPACEMF.IN queue.

    The message flow parses the XML message and writes an XML message that use namespaces. The output message is put to the CHANGENAMESPACEMF.OUT queue.

  4. You might have to select Source from the Viewer menu to see the output message in the Test Client.
  5. Compare the received message with the expected output message, or with file CHANGENAMESPACEout.xml.

If all the steps are successful, then the sample is complete.

Expected output message

The expected output XML message is:

<?xml version="1.0" encoding="UTF-8"?>
<NS1:SaleListMessage xmlns:NS1="http://www.samplemessage.brokertest.hursley.ibm.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.samplemessage.brokertest.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>GBP</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>EUR</Currency>
        </Invoice>
    </SaleList>
    <Trailer>
        <CompletionTime>2000-01-01 00:00:01.000000</CompletionTime>
    </Trailer>
  </SaleEnvelope>
</NS1:SaleListMessage>

Back to sample home