Click here to Skip to main content
15,879,535 members
Articles / Programming Languages / C# 4.0

Envelope Schema and Debatching

Rate me:
Please Sign up or sign in to vote.
4.00/5 (5 votes)
27 Dec 2012CPOL6 min read 57.7K   7   6
Debatching the messages in BizTalk

Introduction

Hi all, I am so glad  that I am submitting my very first article over internet. The reason being from the day  I started learning this technology , I found that very less internet support for the BizTalk technology as compared to other technology that are there in the market. So it is just an attempt  from my side to provide a potential learning  support  towards the technology. 

I scratched my brain over a days to understand the concept (debatching) which I am going to speak in a while. I read few books but none of them are able to give the clear cut idea about what exactly the concept is meant for. So  I am explaining  the same concept in very brief manner... Happy reading ... 

The  concept which I am going to share is debatching  a message using envelope schema in BizTalk server. The moment we here the term debatching, first question that  hits our mind is what is debatching? All right let me address that first and move forward.

In simple words debatching is the process of extracting the individual message/record from a file that contains multiple records/messages and creating different separate files for all those individual message/records to process them separately. For ex: Say supposing there is an XML file that contains order details of three orders. Please look at the below XML file :

Image 1

Orders.XML

So if I give the file that contains above order  details as input to my application, what debatching says is that I should get 3 separate individual messages each containing its own order detail like this:

Image 2  

order1.xml 

Image 3

order2.xml 

Image 4

order3.xml 

Sounds cool,So how can we achieve this debatching pragmatically in our biztalk? The solution to this is biztalk achieves debatching through envelope schema. So lets learn about envelope schema. Envelope schemas are the normal schemas which provides you an ability to define the container schema that wraps number of child schemas (In our ex. its the schema that defines individual orders). Its is this envelope property of the normal schema that allows you to access the child records(order) individually and process those individually.

Let's look at the structure of both child schema (OrderSchema.xsd) and envelope schema (OrderEnvelopeSchema.xsd) that wraps the child schema.

Image 5

OrderEnvelopeSchema.xsd

Image 6

OrderSchema.xsd 

Steps to create such application:

a. Create a schema for the record or message which you want repeat that in the input file. In my case it is OrderSchema.xsd.

b. Create envelope schema (It ll be explained in detail later in the article)

c. Test your input through command line tool xmldasm.exe 

 ***************************************************************************************************************

a. Create a schema for the record or message which you want repeat that in the input file. In my case it is OrderSchema.xsd.  

1. Open Visual Studio choose empty BizTalk template, add new project and name it as BatchProcessing.sln

2. In Solution Explorer right click on the BatchProcessing project add new item add a schema and name it as OrderSchema.xsd

3. Rename the root node to Order.

4. Right click on the Order root node then insert schema node and insert child element and rename it as OrderId

 5. Repeat the step 4 and rename the node as OrderAmount. Go to file menu and save all .

So the ultimately the structure should look like OrderSchema.xsd image.

b. Create envelope schema. 

1. Right-click the project, and select Add  New Item to open the Add New Item dialog box.
2. Select Schema Files from the BizTalk Project Items category and Schema from the list of templates. Enter a descriptive name for your new schema and then click Add. In this case, OrderEnvelopeSchema will be used.
3. Right-click the Root node of the new schema, and change it to the root name of the incoming schema containing the batch of records (OrderEnvelope in this example).
4. Right click the Schema node (directly above the newly renamed root node), and change the Envelope property of the schema to Yes (in the Properties window). 
5. Right-click the newly renamed root node, and select Insert Schema Node Child Record, Child Field Attribute, or Child Field Element, to add the appropriate envelope elements. In this example, a child field element named BatchID and a child record named Orders, which will contain the child records  which we are going to send in our input document.
6. Right-click the record that will contain the child records (Orders in this example) and select Insert Schema Node ➤ Child Record to add a container for the child records. In this example, a child record named Order is added.

7. Right-click the container child record (Order in this example), and select Insert Schema Node  Any Element to add a placeholder for the child elements. The resulting envelope schema has the structure shown in Figure OrderEnvelopeSchema.xsd

8. Click the root node (OrderEnvelope in this example), and click the Body XPath property of the schema (in the Properties window), which will open the Body XPath dialog box.

Image 7


9. Navigate through the schema structure displayed in the tree view, and select the container record for the child records you wish to process individually (the Orders record in this example), as shown in below Figure Then click OK.

Image 8

 So tats it..  Go to  file menu save all the solution, now our both schemas are ready to test the input.

c. Test your input through command line tool xmldasm.exe  

xmldasm.exe is the command line tool provided by BizTalk to test the debatching over command line with out being deployed our solution in Admin console.

1.Go to C:\Program Files(*)\Microsoft BizTalk server 2010\SDK\Utilities\PipelineTools copy both xmldasm.exe and PipelineObjects.dll to the folder where you have your schema files.

or

 If you don't want to copy the files the alternative way is goto command prompt just type

path = %path%;”C:\Program Files (x86)\Microsoft BizTalk Server 2010\SDK\Utilities\PipelineTools”  hit enter.

(Here we are just setting the path environment variable to the OS .lets not worry about that much)

 2. Copy the input file and paste under the same directory. Your input file ll look like: (Orders.xml

Image 9

Notice that the input file contains three order details along with that it is wrapped up by the body header that is OrderEnvelope. This is because of the reason we are going validate our input file against the envelope schema before debatching , As out envelope contains some header information our input xml file also should contain the same in order to by pass.

2. Open command prompt and execute the following command : xmldasm Orders.xml -ds OrdersSchema.xsd -es OrderEnvelopeSchema.xsd -c hit enter.

The preceding command uses the xmldasm utility; xmldasm is used to simulate the use of an XML disassembler component in a pipeline. The parameters used are: message (Orders.xml), -ds (documentschema = OrdersSchema xsd), -es (envelope schema = OrderEnvelopeSchema.xsd) and –c (display results in the console). 

This will display the debatched message on the console. 

Thanks for your time . Appreciate your valuable feedback for improvisation in upcoming article...       

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior) Wipro Technologies
India India
For any doubts and clarification regarding the article,Please reach me out at amsuprith@gmail.com

Comments and Discussions

 
QuestionMap on receive port from debatched message to Canonical Pin
Member 1154772922-Jul-19 21:35
Member 1154772922-Jul-19 21:35 
Questiondebatching and batching Pin
Amit Patel198514-Mar-15 8:08
Amit Patel198514-Mar-15 8:08 
Hi All,

I have one scenario where envelop schema is coming and I want to debatch it. those debatch xml may have same transaction id if transaction id is same then i need to batch it again. thoughts

Please share your thoughts if you have any sample please share with me

Thanks,
Amit Patel
GeneralVery detailed and descriptive Pin
rkkota3-Aug-14 15:12
rkkota3-Aug-14 15:12 
QuestionNice Article Pin
RatnakarSinha22-May-14 3:20
RatnakarSinha22-May-14 3:20 
QuestionGood Article Pin
Shrilata Ellaboina10-Nov-13 22:59
Shrilata Ellaboina10-Nov-13 22:59 
AnswerRe: Good Article Pin
Suprith A.M12-Nov-13 3:27
Suprith A.M12-Nov-13 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.