Debatching(Splitting) XML Message - BizTalk 2010
In this post we will walk through the process of debatching xml message using Biztalk.
Scenario:
We receive many item information but its wrapped(Enveloped) , so to process each item we need to unwrap it ( remove envelope and split individual Item message.Below is what we receive(Input) :
<ns0:Items xmlns:ns0="http://TestingSchemas.ItemEnvelope">
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_0</ID>
<Name>Name_0</Name>
<Quantity>100</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_0</ID>
<Name>Name_1</Name>
<Quantity>200</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_2</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_3</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_4</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_5</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_6</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_7</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_8</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
<ID>ID_9</ID>
<Name>Name_2</Name>
<Quantity>300</Quantity>
<UnitPrice>100</UnitPrice>
</ns1:Product>
</ns0:Items>
But we want(Output) :
<ns0:Product
xmlns:ns0="http://TestingSchemas.Item">
<ID>ID_0</ID>
<Name>Name_0</Name>
<Quantity>100</Quantity>
<UnitPrice>100</UnitPrice>
</ns0:Product>
.
.
.
.
.
<ns0:Product
xmlns:ns0="http://TestingSchemas.Item">
<ID>ID_9</ID>
<Name>Name_9</Name>
<Quantity>100</Quantity>
<UnitPrice>100</UnitPrice>
</ns0:Product>
Allright , lets see how we do it:
1. Create schema - document schema
2. Create the wrapper - Envelope Schema
- Click on "Schema" and go to Properties Window
- Set the property "Envelope" as Yes , as this schema will be used as envelope and this is the property which helps disassembler to recognize it.
- So far good , envelope schema is ready but what about the document which will be wrapped.
- In the Property window select "Imports" and click on the ellipsis
- You will get Imports wizard pop-ed out .
- Click on add and select the document schema which we created in step 1.(Here it is Item schema)
- Click on the "Items" and go to property window and select the property Body XPath and set it to
3. Now create a Receive port which will receive enveloped message(ItemEnvelope Type) .- Select XMLReceive pipeline
4.Now create a Send port which will send individual xml message (Item Type)- Select XMLTransmit pipeline
- Add Filter (this creates subcription ) : BTS.ReceivePortName == ReceiveItem
- After splitting the message , the pipeline would submit individual Item Messages and as we are creating subscription , all the messages submitted by ReceiveItem port will be picked by SendPort
5. Now lets test, I will drop a envelope message at receive location which we saw at start . So I should be getting 10 individual xml message at the destination location:6.Did we really got the messages split-ted:Will keep on posting as an when I find something to share!!!!!!!!!!!!
Comments
Post a Comment