BizTalk - debatch (split) 1 xml containing many records to multiple flat files

I have 1 xml file with multiple records in it. My requirement is I have to split each record as a flat file. How can I achieve this ? I am stuck. I am not sure if Envelope schema will work, because I tried and it didn't work.

If Envelope schema is the only way of doing it, I may be doing something wrong with creating Envelope schema. Can anyone please give me step by step procedure using Envelope&

July 3rd, 2015 11:26pm

Hi ,

What you can do is to debatch the incoming message at pipeline level through Envelope batching and subscribe your Orchestration with the document schema (debatched message ) .

In Orchestration you can call Pipeline component to convert debatched message into Flat file . For Refer http://msdn.microsoft.com/en-us/library/aa562035.aspx - How to use Expression to Execute Pipelines .

and another blog post by Abdul Rauf

Calling Send and Receive Pipelines from the orchestration expression shapes

Code for the article is available here (this is not mentioned in the article)

http://abdulrafaysbiztalk.wordpress.com/files/2009/06/processingflatfiles.doc

While calling the pipeline in Orchestration, you will be use the cod

Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteSendPipeline(typeof(YourSendPipelineWhichConvertXML2FlatFile), SendPipelineInput, OutputMessage);

Thanks

Abhishek


Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 2:01am

Hi ,

You can follow the post for how to debatch xml using Envelope schema: http://tech-findings.blogspot.in/2013/07/debatchingsplitting-xml-message-biztalk.html

Once you have debatched message, you can apply map(on port) which transforms individual xml message to flat file.

July 4th, 2015 5:08am

Hi Abhishek, I am having hard time to set debatching .My scenario is I have fixed source schema for which there will be an xml coming in with multiple records. Below is the instance of the xml

<?xml version="1.0" encoding="utf-8"?><ns0:Root xmlns:ns0="http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR"><req CpnyId="1011" VendId="21000002289" InvcNbr="20150603E" InvcDate="2015-06-03+00:00" ReqAmt="1100"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="550.00" Descr="" /><rit CpnyId="1011" Acct="6001880" Sub="AU00-00000-101000-ACE-00-000" TranAmt="550.00" Descr="" /></req><req CpnyId="1011" VendId="21000002289" InvcNbr="20150603A" InvcDate="2015-06-01+00:00" ReqAmt="7171"><rit CpnyId="1011" Acct="6001880" Sub="AU00-00000-101000-ACE-00-000" TranAmt="7171.00" Descr="AX Test" /></req><req CpnyId="1011" VendId="21000002289" InvcNbr="20150603B" InvcDate="2015-06-01+00:00" ReqAmt="248"><rit CpnyId="1011" Acct="6001880" Sub="AU00-00000-101000-ACE-00-000" TranAmt="88.00" Descr="AX Test" /><rit CpnyId="1011" Acct="4000010" Sub="AU00-00000-101000-ACE-00-000" TranAmt="80.00" Descr="AX Test" /><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="80.00" Descr="AX Test" /></req></ns0:Root>

and this is the schema for it....I need to debatch each record in the xml instance into flat file

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="unbounded" name="req">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="1" maxOccurs="unbounded" name="rit">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="CpnyId" type="xs:string" use="required" />
                      <xs:attribute name="Acct" type="xs:string" use="required" />
                      <xs:attribute name="Sub" type="xs:string" use="optional" />
                      <xs:attribute name="TranAmt" use="required">
                        <xs:simpleType>
                          <xs:restriction base="xs:decimal">
                            <xs:minExclusive value="0" />
                          </xs:restriction>
                        </xs:simpleType>
                      </xs:attribute>
                      <xs:attribute name="Descr" type="xs:string" use="required" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="CpnyId" type="xs:string" use="required" />
            <xs:attribute name="VendId" type="xs:string" use="required" />
            <xs:attribute name="InvcNbr" type="xs:string" use="required" />
            <xs:attribute name="InvcDate" type="xs:date" use="required" />
            <xs:attribute name="ReqAmt" use="required">
              <xs:simpleType>
                <xs:restriction base="xs:decimal">
                  <xs:minExclusive value="0" />
                </xs:restriction>
              </xs:simpleType>
            </xs:attribute>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="VendId_InvcNbr">
      <xs:selector xpath="req" />
      <xs:field xpath="@CpnyId" />
      <xs:field xpath="@VendId" />
      <xs:field xpath="@InvcNbr" />
    </xs:unique>
  </xs:element>
</xs:schema>

Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 7:22am

Hello Mahesh, I already went through the link you mentioned, but was unable to create debatched message. If you see above my Source schema is fixed....can you please tell me the steps how can I achieve this ? I tried creating a separate document schema and envelope schema and mapped my original schema to Envelope schema but it isnot debatching ? what am I doing wrong. The link that you provided, for every record it has namespace, my instance does not have that. You can see my xml and schema in above post
July 4th, 2015 7:42am

Is there anyway for this below instance I can create debatched (split)individual records in separate files ? If it creates a separate xml file als that will work in my requirement. Below is the xml instance

<?xml version="1.0" encoding="utf-8"?><ns0:Root xmlns:ns0="http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR"><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A20" InvcDate="2015-04-01+00:00" ReqAmt="14.85"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="14.85" Descr="K Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A21" InvcDate="2015-04-02+00:00" ReqAmt="863.6"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="863.60" Descr="L Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A22" InvcDate="2015-04-04+00:00" ReqAmt="59.73"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="59.73" Descr="M Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A23" InvcDate="2015-04-06+00:00" ReqAmt="34.45"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="34.45" Descr="N Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A24" InvcDate="2015-04-08+00:00" ReqAmt="42.45"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="42.45" Descr="O Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A25" InvcDate="2015-04-10+00:00" ReqAmt="56"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="56.00" Descr="P Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A26" InvcDate="2015-04-11+00:00" ReqAmt="44.55"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="44.55" Descr="Q Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A27" InvcDate="2015-04-12+00:00" ReqAmt="45.97"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="45.97" Descr="R Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A28" InvcDate="2015-04-13+00:00" ReqAmt="11.22"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="11.22" Descr="S Test" /></req><req CpnyId="1011" VendId="21000003034" InvcNbr="INVOICE-A29" InvcDate="2015-04-14+00:00" ReqAmt="14.85"><rit CpnyId="1011" Acct="4000010" Sub="US00-DLSMD-102000-000-10-AC3" TranAmt="14.85" Descr="T Test" /></req></ns0:Root>

Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 7:54am

Ok, here you go:

I used the sample xml file provided by you and created an application and am able to debatch it, follow below steps

1. Create document schema with targetnamespace as blank (I have used only two attributes)

2. Create envelope schema

Remember to set property Envelope to Yes  and Body_Xpath to Root Node

3. Deploy solution, create rcv port and location, use Xmlreceive pipeline

4. Create Sendport with a filter as BTS.ReceivePortName = above created rcv port name

5. drop test file at receive location 

6. You should see debatched file at destination location.

7. For the next part, xml to flat file. You need to crate a flat file schema

8. Map from xml to flat file and use it on send port.

July 4th, 2015 9:18am

Thanks Mahesh, but on giving Target namespace

1) http://Brightstar.Integration.Serengeti.IPM.Schemas.IPM_SR  in Envelope schema, as this namespace is being used and deployed. So will this not create any schema mismatch during deployment ?

2) Do I need to mention anything in Receive XML pipeline in properties about document/envelope schema ?

Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 9:29am

I assume you are reffering to same schema, you can go ahead and delete it (as it was not correct) and deploy the new one. 

No(you can) , but not required.

July 4th, 2015 9:37am

Iam sorry but I didnt get you what you mean go ahead and delete ? Can you please be clear ? Or send a screenshot of Envelope schema again with nameapace ?
Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 9:41am

:)

What I meant, you have created a envelope schema with same Namespace and root node, then delete that and remove the deployed schema from Admin console (so that you don't get error for multiple schema) -- as you will be creating new based on what I posted above.

I can send you the schemas for your convenience, if you can share your email id . 

July 4th, 2015 9:49am

1) but the thing is the xml instance I provided for (IPM _SR) is binded to other application. There is a map which is transforming the instance I provided you. Taking this i have to debatch, hope you understood my point. 2) itsburhaan@live.com
Free Windows Admin Tool Kit Click here and download it now
July 4th, 2015 9:53am

I have sent you files and explanation to on your email
July 4th, 2015 10:08am

HI jaguarjags,

Do you solve this issue? if it still has same issue, please let us know.

With regards,

Angie

Free Windows Admin Tool Kit Click here and download it now
August 2nd, 2015 9:36pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics