Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / biztalk

Split XML Interchanges on BizTalk

4.00/5 (1 vote)
20 Apr 2011CPOL1 min read 11.3K  
How to split XML Interchanges on BizTalk

Introduction

An interchange is a group of messages that are contained within one larger message. In this post, I describe how to split an XML interchange into individual messages to be processed and saved to the MessageBox on BizTalk Server.

The interchange and the messages

The interchange in this case is shown below.
<Envelope Type="Updates" xmlns="http://Stm.Messaging.Schemas.Updates">
   <Updates>
      <CompanyUpdate CompanyID="1" Name="Company A" Address="Street 1" />
      <CompanyUpdate CompanyID="2" Name="Company B" Address="Street 2" />
      <CompanyUpdate CompanyID="3" Name="Company C" Address="Street 3" />
   </Updates>
 </Envelope>
The interchange will be split into single CompanyUpdate messages.
<CompanyUpdate CompanyID="1" 
               Name="Company A" 
               Address="Street 1" 
               xmlns:ns0="http://Stm.Messaging.Schemas.Updates" />

Create an envelope Schema

The first thing to do is to create an envelope schema. This can easily be done by using the Add Generated Schemas in Visual Studio and generate a schema from the interchange. In the schema node, set the Envelope property to Yes. In the root node (In this case Envelope node), set Body XPath property to the parent node of the body messages. (In this case, the Updates node) In the body messages node (CompanyUpdate node), set Data Structure Type property to xs:anyType. In this example, I have also set the Target Namespace to the Schema.

Create a Schema for the individual messages

Create a CompanyUpdate Schema (Add Generated Items) from an individual message.

Deploy and test

Deploy the two schemas and use the XMLReceive pipeline in a receive location. This will split the interchange into individual CompanyUpdate messages with
Target Namespace = "http://Stm.Messaging.Schemas.Updates"
and
Root Node = "CompanyUpdate"

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)