Debatching(Splitting) XML Message in Orchestration using DefaultPipeline - BizTalk 2010
In this post we will walk through the process of debatching an xml message in Orchestration using pipeline in Biztalk.
I have used the Default XML Receive pipeline to achieve it, but it can also be done by creating a custom pipeline which uses XML disassembler (where you can set the Envelope and Document Schema).
Pipeline is not available in Orchestration like other shapes, thus to use it we need to add reference to following assemblies(which will allow us to use methods in those assemblies) :
You can browse to the location BizTalk Installation Directory to find above dll's.
Most of the part of this post is borrowed from my earlier post which talks about debatching xml at receive port:
http://tech-findings.blogspot.in/2013/07/debatchingsplitting-xml-message-biztalk.html
We receive many item information but its wrapped (Enveloped) , so to process each item we need to unwrap it (remove the envelope and split individual Item message).
Below is what we receive (Input) :
I have used the Default XML Receive pipeline to achieve it, but it can also be done by creating a custom pipeline which uses XML disassembler (where you can set the Envelope and Document Schema).
Pipeline is not available in Orchestration like other shapes, thus to use it we need to add reference to following assemblies(which will allow us to use methods in those assemblies) :
- Microsoftdll
- Microsoftdll
You can browse to the location BizTalk Installation Directory to find above dll's.
Most of the part of this post is borrowed from my earlier post which talks about debatching xml at receive port:
http://tech-findings.blogspot.in/2013/07/debatchingsplitting-xml-message-biztalk.html
Scenario:
We receive many item information but its wrapped (Enveloped) , so to process each item we need to unwrap it (remove the envelope and split individual Item message).
Below is what we receive (Input) :
<ns0:Product >
<ID>ID_0</ID>
<Name>Name_0</Name>
<Quantity>100</Quantity>
<>
</ns0>
.
.
.
.
.
<ns0:Product >
<ID>ID_9</ID>
<Name>Name_9</Name>
<Quantity>100</Quantity>
<>
</ns0>
All right, let's see how we do it:
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- .
- 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 /*.ItemEnvelope']. Doing so allows an 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 lets create Orchestration which will receive the enveloped item and debatch/split it using the pipeline.
- Receive shape is configured to receive .
- Then we have a "DebatchScope" which is of type "Atomic" and Orchestration is of type Long running. Why Atomic scope? Because we will be calling/executing Pipeline within it and the pipeline is of non- serializable type.
- Next we have splitted messages.
- It contains ItemsIn);
- .ReceivePipelineOutputMessages
- So we are executing the method ExecuteReceivePipeline.Pipeline and its output assigned to GetPipelineOutput.
- Then we have a loop shape "UntilLastMessage" and its same as while loop, below is the condition()
- Next following code:
ItemOut = null;
ItemOut);
It is here where the xsd
- At .
- Now what, build the project .
- Receive Pipeline is PassThruReceive as we don't want its message type to be detected until the message reaches to ExecutePipeline shape in Orchestration.
- Now after both the ports are ready, it's time to bind it to the logical ports of our orchestration:
5. Start the application and test it, I will drop 10 individual xml message at the destination location:
Will keep on posting as an when I find something to share!!!!!!!!!!!!