Sunday, March 7, 2004 12:02 AM Jan Tielens

How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

It’s a little disappointment but the documentation in the RTM version of BizTalk 2004 is quite limited. There will be an updated set of docs available in late March/early April but that’s not a solution for now. Therefore I’m posting my early experiences with this product: no rocket science but basic things I struggled with a little bit. The first example is how to split a large XML message into parts, so each part can be processed separately.

Image you have following message that contains information about one or more customers; the Customers node can contain any number Customer nodes.
<Customers>
    <Customer>
        <CustomerID>1</CustomerID>
        <Name>Customer One</Name>
    </Customer>
    <Customer>
        <CustomerID>2</CustomerID>
        <Name>Customer Two</Name>
    </Customer>
</Customers>
Suppose you don’t want to process all the customer’s at once, but you want to be able to process each Customer node one by one in your orchestration. This can be done by using a Envelope schema and a Document schema: the envelope (Customers node) contains any number of documents (Customer node). So let’s create these schema’s in BizTalk:

  1. Start a new empty BizTalk project and add a new schema, name it for example CustomerDocument.
  2. Change the name of the Root node to something more descriptive like “Customer”.
  3. Add the “CustomerID” and “Name” properties as Child Field Elements to the schema.
  4. That’s it for the Document schema, so let’s add a new schema to the project and name it “CustomersEnvelope”.
  5. Identify the new schema as an envelope  by selecting the Schema node and change the Envelope property to Yes in the Properties window.
  6. Change the name of the Root node to “Customers”.
  7. You can import the document schema into the envelope schema by clicking on the ellipsis button for the Imports property of the Schema node. You’ll get a dialog window in which you add an “XSD Import” of the CustomerDocument schema. Then add a new Child Record node under the Customers node and name it Customer. Set the Data Structure Property of this new node to “ns0:Customer” (if you haven’t changed the namespace). If you don’t want to use an XSD Import, you can set the Data Structure Property to “xs:anyType”.
  8. Change to “Body XPath” property of the Customers node by clicking the ellipsis button and point to the Customers node. The property will be set to: /*[local-name()='Customers' and namespace-uri()='http://XMLSplitExample.CustomersEnvelope']

Next you need to configure a new ReceivePipeline in which the schemas created above will be used:

  1. Add a new ReceivePipeline to your project and name it CustomerReceivePipeline for example.
  2. Add a XML disassembler to the Disassemble stage of the ReceivePipeline.
  3. Set the Document schemas property of that XML disassembler to the CustomerDocument schema.
  4. Set the Envelope schemas property of the XML disassembler to the CustomersEnvelope schema.

Now the CustomersReceivePipeline can be used in an orchestration; so let’s do that:

  1. Add a new orchestration to the project.
  2. Add a port to the orchestration that will receive the messages.
  3. Set the Receive Pipeline property of that port to CustomersReceivePipeline (the one that we’ve created above).
  4. Now you can add a Receive shape to the orchestration that receives a message of the CustomerDocument shema type.

Next you’ll need to add your logic to the orchestration. As a result of the receive pipeline, the Customers node will be disassembled into Customer nodes that will be passed into your orchestration as separate messages. I need to thank Christof Claessens for his recommendations. Christof is guy that really knows a lot of BizTalk 2004, I’ve talked to him a couple of times and each time I learn something new, thanks!

Filed under:

Comments

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Friday, March 26, 2004 8:32 AM by Roland

I face an additional problem. In addition to splitting a message, I want to have envelope fields available in my orchestration, e.g. attribute receiveDate when the envelope contained a root element like <customers receiveDate="...">.

Is this possible?

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Tuesday, March 30, 2004 2:43 AM by Paul O'Donnell

Thanks for this info Jan. I have been trying to do get Biztalk to do this. And your post definately helped. I have an issue though and was wondering if you know what it is..

I created a sample XML as specified above and passed it through this process. The file is removed from the input, but no output is produced. I changed the test XML file to contain the schema information as below and this processes fine, two messages are produced in my output. Any ideas why I need to have the schemas included?

<ns0:Customers xmlns:ns0="http://MultiCustomer.CustomersEnvelope">
<ns1:Customer xmlns:ns1="http://MultiCustomer.CustomerDocument">">http://MultiCustomer.CustomerDocument">
<CustomerID>1</CustomerID>
<Name>Customer One</Name>
</ns1:Customer>
<ns1:Customer xmlns:ns1="http://MultiCustomer.CustomerDocument">">http://MultiCustomer.CustomerDocument">
<CustomerID>2</CustomerID>
<Name>Customer Two</Name>
</ns1:Customer>
</ns0:Customers>

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Wednesday, April 7, 2004 7:33 PM by srini

is it posible to split my output xml file in Send port.

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Thursday, April 8, 2004 12:51 AM by Jan

Srini, I'm not aware of any methods to do this.

# orchestration details

Wednesday, April 28, 2004 10:12 PM by Nina

Hi
I am new to Biztalk and would appreciate if any body has the posting on how to create the orchestration of this sample.
Regards
Nina

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Tuesday, May 4, 2004 8:38 AM by Hasan

I've done all that you've described. However I have this poblem that I am getting one file(exact copy of the input file) as the output. I would like to have two files (two customers)
as the output.
The only thing i've done differently is that instead of an orchestration, I've added a send port and subscribed to all messages arriving at the receive location.

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Thursday, June 17, 2004 1:05 PM by Brian

Encountered same error as Emiel.

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Wednesday, June 23, 2004 8:25 AM by John C.

I had the same failure on the receive pipeline. Undeploying doesn't clean out the GAC as you would expect. I fixed it by incrementing the version of the project and re-deploying.

# How to include an XML message in BizTalk 2004 using Document & Envelope Schemas

Wednesday, June 23, 2004 11:30 AM by Ram

Hi
Iam trying to add header file to my output given by mapper and attach header file in send pipeline.I have tried with my header schema to give as header file to my output.Thanks
Ram

# re: Splitting inbound flat file into outbound multiple XML messages...

Tuesday, July 6, 2004 6:10 PM by Hank Beasley

for your question about spliting flat files into multiple xml docs
check C:\Program Files\Microsoft BizTalk Server 2004\SDK\Samples\Pipelines\AssemblerDisassembler\EnvelopeProcessing.

You shall find the anwser you seek.

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Wednesday, July 7, 2004 8:01 AM by Rebecca

Anyone know what settings I would have to change to go from the following schema:
<ns0:Customers xmlns:ns0="http://Test.customersenvelope">
<ns1:Customer xmlns:ns1="http://Test.CustomerDocument">">http://Test.CustomerDocument">
<CustomerID>1</CustomerID>
<Name>Customer One</Name>
</ns1:Customer>
<ns1:Customer xmlns:ns1="http://Test.CustomerDocument">">http://Test.CustomerDocument">
<CustomerID>2</CustomerID>
<Name>Customer Two</Name>
</ns1:Customer>
</ns0:Customers>
To this simpler one:
<Customers>
<Customer>
<CustomerID>1</CustomerID>
<Name>Customer One</Name>
</Customer>
<Customer>
<CustomerID>2</CustomerID>
<Name>Customer Two</Name>
</Customer>
</Customers>
Thanks for the awesome example!

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Tuesday, June 6, 2006 12:51 AM by Pankaj

Great article.

How do we do this using .NET component?

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Thursday, June 29, 2006 2:15 AM by elad rosenberg

Great article.

It's working great on file adapter but not with SOAP...

any help will be appriciated.

eladr@tip.co.il

# re: How to split an XML message in BizTalk 2004 using Document & Envelope Schemas

Tuesday, April 3, 2007 10:53 AM by fdxy

<a href= http://sugar-free.150m.com >Home gift baskets</a>   <a href= http://foodgi.150m.com/index2.html">http://foodgi.150m.com/index2.html >gift basket</a>   <a href= http://foodgi.150m.com/ >gift baskets new jersey</a>   <a href= http://sugar-free.150m.com >new grandparents gift baskets</a>   <a href= http://sugar-free.150m.com >corporate gift basket scheduled delivery</a>   <a href= http://foodgi.150m.com/ >gift baskets gourmet</a>   <a href= http://sugar-free.150m.com >basket business gift home start</a>   <a href= http://sugar-free.150m.com >gift baskets champagne and chocolate</a>   <a href= http://marginall.150m.com/ >taffy christmas gift basket from north carolina</a>   <a href= http://sugar-free.150m.com >wine gift baskets maryland</a>