In this post we will walk through the process of debatching xml message using Biztalk.
Scenario
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:
Steps in creating solution
1. Create schema - document schema
2. Create the wrapper - Envelope Schema
- Name the root node, I have named it Items.
- 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 /*[local-name()='Items' and namespace-uri()='http://TestingSchemas.ItemEnvelope']. Doing so allows Items node to contain any number of Item Document.
- Cool... now we are ready with the resources, next is to validate schema ,build it, sign it and deploy.
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!!!!!!!!!!!!
If you have questions or suggestions, feel free to do in comments section below !!!
Do share if you find this helpful .......
Knowledge Sharing is Caring !!!!!!
Related Post
- BizTalk Server: Multiple XML files to Single FlatFile Using File Adapter
- BizTalk 2013: Inserting RawXML (Whole Incoming XML Message) in SQL database
- BizTalk 2013: Inserting RawXML (Whole Incoming XML Message) in SQL database - Part 2
- Is it possible to have Map Chaining on the Port Level
- Promoting custom context property using Pipeline Component
- Custom ZipReceivePipeline to Unzip Multi-Type Messages
- Grouping and debatching Inbound Messages from WCF SQL Adapter - BizTalk 2010
- Polling data from SQL using WCF-SQL Adapter in BizTalk 2010 - TypedPolling(From Multiple table)
- Grouping XML Messages using custom XSLT- BizTalk 2010
- Insert Records in SQL Server using WCF-SQL Adapter in BizTalk 2010 - Composite operation(Multiple Records insertion)
- Insert Records in SQL Server using WCF-SQL Adapter in BizTalk 2010- Composite Operation (Message Transformation Pattern)
- Debatching(Splitting) XML Message - BizTalk 2010
- Debatching(Splitting) XML Message in Orchestration using DefaultPipeline - BizTalk 2010
Sorry for replying on the old thread , but did you change the "Data Structure Type" when you finished the Import step on step 2?
ReplyDelete