You can use Envelope schema to Split up a Batch XML into individual Files or Split up an XML file that has more that one Embedded XML files into individual Files. This is show below.
- Split up a Batch XML into Individual XML files.
Eg: Input – Batch XML File
<Items>
<Item>
<ID>1</ID>
</Item>
<Item>
<ID>2</ID>
</Item>
</Items>
Output - two Individual XML Files
<Item>
<ID>1</ID>
</Item>
and
<Item>
<ID>2</ID>
</Item>
- Split up an XML file that has more than one Embedded XML files into individual Files
Eg: Input – Has two types of XML Files
<Items>
<Item1>
<ID1>1</ID1>
</Item1>
<Item2>
<ID2>2</ID2>
</Item2>
</Items>
Output – Two separate xml files
<Item1>
<ID1>1</ID1>
</Item1>
and
<Item2>
<ID2>2</ID2>
</Item2>
Solution:
- Create a new BizTalk Server Project and two Schemas – Schema1 & Schema2 as shown below
- Create a new Schema Schema3 and rename the Root Node to Envelope or some thing else
- Scheme and Go to Properties and make Envelope property to Yes
- Now select the Root Node Envelope and Go to Properties. Click on the Ellipses next to Body XPath and Select the Root Node itself. ( Here you are specifying that the Body of the Envelope starts with the Root Node itself)
- Deploy the Application
- Create One File Receive Port and 2 File Send Ports. Use XML Receive pipeline for Receive Port and pass through pipeline for the send ports.
- Since we are not using any orchestrations for receiving/routing the separated individual XML files, we have to set the Filter properties of Both the send ports to Subscribe for the individual XML files as given below.
- Create an Envelope XML file which has Embedded XML files of Schema1 & Schema2
- Drop the above XML in the Receive Folder. Very soon it will be split up into 2 separate XML Files
- These two will be stored in the two folders specified in the Send Ports
For Send Port1 - BTS.MessageType == http://BizTalk_Server_Project2.Schema1#Root1
For Send Port2 - BTS.MessageType == http://BizTalk_Server_Project2.Schema2#Root2
Note: Change the Values according to your project, schema and Root Names. It should be in the format TargetNamespace+#+RootName
<ns0:Envelope xmlns:ns0="http://BizTalk_Server_Project2.Schema3">
<ns1:Root1 xmlns:ns1="http://BizTalk_Server_Project2.Schema1">
<Field1>Field1_0</Field1>
</ns1:Root1>
<ns2:Root2 xmlns:ns2="http://BizTalk_Server_Project2.Schema2">
<Field2>Field2_0</Field2>
</ns2:Root2>
</ns0:Envelope>
<ns1:Root1 xmlns:ns1="http://BizTalk_Server_Project2.Schema1">
<Field1>Field1_0</Field1>
</ns1:Root1>
and
<ns2:Root2 xmlns:ns2="http://BizTalk_Server_Project2.Schema2">
<Field2>Field2_0</Field2>
</ns2:Root2>
- Shiv
No comments:
Post a Comment