You can use XML messages that do or do not make use of namespaces in IBM Integration Bus.
Here is an example of a message that does not make use of namespaces:
<?xml version="1.0" encoding="UTF-8"?> <SaleListMessage> <SaleEnvelope> <Header> <SaleListCount>1</SaleListCount> </Header> <SaleList> <Invoice> ..... </SaleList> <Trailer> <CompletionTime>2000-01-0100:00:01.000000</CompletionTime> </Trailer> </SaleEnvelope></SaleListMessage>
Here is an example of a message that does make use of namespaces:
<?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> ..... </SaleList> <Trailer> <CompletionTime>2000-01-0100:00:01.000000</CompletionTime> </Trailer> </SaleEnvelope> </samp:SaleListMessage>
This sample contains a message set and three message flows.
The message set CHANGENAMESPACEMS has a runtime domain of XMLNSC and contains message definition files generated from three XML schemas:
The message definition files all model the SaleListMessage that is used in many of the IBM Integration Bus samples. These message definitions are identical apart from their namespaces. The schemas are required to validate the messages on entering and leaving the message flows.
IBM Integration project CHANGENAMESPACEMF contains the following message flows:
Descriptions of each of these message flows:
This message flow comprises MQInput, Compute, and MQOutput nodes.
The message flow receives an XML message over WebSphere MQ protocol, and outputs an XML reply message by using WebSphere MQ. The XMLNSC parser is used by the message flow and validation is active.
The WebSphere MQ input message contains no elements with namespaces. The message flow adds a namespace to the root element of the message. The WebSphere MQ input message can contain an MQRFH2 header to specify the target namespace dynamically. The header must contain the following in the NameValueData element:
<usr> <targetNamespace>URL2</targetNamespace> <targetSchemaLocation>URL3</targetSchemaLocation> </usr>
The targetSchemaLocation element is optional.
If no MQRFH2 header is present, or if the MQRFH2 header cannot be processed, the namespace is changed according to the following values:
The Compute node calls an ESQL function called ChangeNamespaceInOutputRoot. For details of the ESQL function, see Building the XMLNSC Namespaces sample.
This message flow comprises MQInput, Compute, and MQOutput nodes.
The message flow receives an XML message over WebSphere MQ protocol and outputs an XML reply message by using WebSphere MQ. The XMLNSC parser is used by the message flow, and validation is active.
The WebSphere MQ input message contains elements with namespaces, and might contain elements from several namespaces. The message flow can change one of the existing namespaces. The input WebSphere MQ message might also contain an MQRFH2 header to specify the source, target, or both namespaces dynamically. The header contains the following in the NameValueData element:
<usr> <sourceNamespace>URL1</sourceNamespace> <targetNamespace>URL2</targetNamespace> <targetSchemaLocation>URL3</targetSchemaLocation> </usr>
The targetSchemaLocation element is optional.
If no MQRFH2 header is present, or if the MQRFH2 header cannot be processed, the namespace is changed according to the following values:
If the source or target does not have a namespace, specify NONAMESPACE as sourceNamespace, targetNamespace, or both.
<usr> <sourceNamespace>URL1</sourceNamespace> <targetNamespace>NONAMESPACE</targetNamespace> </usr>
The Compute node calls an ESQL function called ChangeNamespaceInOutputRoot. For details of the ESQL function, see Building the XMLNSC Namespaces sample.
This message flow comprises MQInput, Compute, and MQOutput nodes.
This message flow receives an XML message over WebSphere MQ protocol and outputs an XML reply message by using WebSphere MQ. The XMLNSC parser is used by the message flow, and validation is active.
The WebSphere MQ input message contains elements with namespaces, and might contain elements from several namespaces. This message flow deletes references to one of the existing namespaces.
The WebSphere MQ input message might contain an MQRFH2 header to specify the source namespace dynamically. The header must contain the following in the NameValueData element:
<usr> <sourceNamespace>URL1</sourceNamespace> </usr>
If no MQRFH2 header is present, or if the MQRFH2 header cannot be processed, the namespace is changed according to the following values:
The Compute node calls an ESQL function called ChangeNamespaceInOutputRoot. For details of the ESQL function, see Building the XMLNSC Namespaces sample.
For a detailed explanation of how to run each sample, see Running the XMLNSC Namespaces sample.