Wednesday, December 24, 2008

Debatching BizTalk XML Messages.

 

What is debatching?

Suppose you are receiving a BizTalk Message  that contains multiple records. In order to process the message and update or send to particular system (DB or any other Application) we need to process this message individually this process called debatching in BizTalk.

How BizTalk helps ?

In BizTalk  using Envelope Schema, Document schema we can process or break a message  individually .

Steps Needed to Achieve this.

1) First Create document schema which has all the elements of the XML  message. and call this schema as Contact.XSD

  Here I am going to use The following XML Message

<Name>Sreeni</Name>
<Age>35</Age>
<Email>sragavan@hotmail.com</Email>

<Name>Gandhi</Name>
  <Age>35</Age>
  <Email>Gandhi@india.com</Email>

2) Create Envelope schema and name it  Contacts

image

Now select Schema node in newly created schema and set Envelope Property to  "YES" as shown above.

Now we need to Import Contact Document schema into Envelope schema.

image

image

Now add child record and name it Contact and change the  Data structure type to  Contact as shown below.

 

image

Now  change the Body Xpath  to /*[local-name()='Contacts' and namespace-uri()='http://XmlDebatching.ContactsEnvelope']

Step 3:

Now create custom Receive Pipeline with XML Disassembler  as shown below.

and Change the document schema to Contact.XSD and  Envelope schema to ContactsEnvelop.XSD.

 

image

finally Add Strong Name key file to the project and Deploy into BizTalk Message DB.

Create  Receive Port with the custom pipeline we created and Send port with  Filters  and  test the application.

Now drop the  Contacts.XML in  Receive Location  and BizTalk Read the message and Split into individual messages as shown here.

image

image

 

image

Thanks

SreenivasaRagavan.

4 comments:

Unknown said...

Hi,Please send me the source code for the same.

Unknown said...

What is the send port filter you used?

Sanket said...

Hi, I need to do the same for a flat file. The flat file disassembler does not have a Envelop schema property. I am using Biztalk 2009. Please do let me know if you have a resolution.
Sanket

Anurag Prajesh said...

it is nice example of debatching,
it solved my problem.

Thanks & Regards
Anurag Prajesh