XPath Debatching and Envelope Debatching Biztalk Lab

Envelopes can be used with the Xml Disassembler in Biztalk 2004 to break up larger Xml messages into single messages.  Another approach to message debatching is to use xpath in a loop inside an Orchestration.  Both these approaches are covered in this Message Debatching Options Lab for Biztalk 2004. 



This lab will take around 40 minutes to complete and is based on Microsoft’s hands-on-labs.



Download: Message Debatching Options Hands-on Lab



Setup is simple.  Unzip the download to your c:\ drive.  Make sure the root folder named “Microsoft Hands-On-Labs” is located at c:\.  The lab manual is located under \ILL009_Debatching.  The exercises are located in the \Source\Exercises folder.  The full sample solution is located in the \Source\Solution folder.



This lab is recommended for beginner and above biztalk users looking to learn more about message debatching in biztalk.


 

Using XPath Inside BizTalk Orchestrations

Working with XPath inside Orchestrations is a powerful and simple feature of BizTalk 2004.  The help guide does a good job describing the process (under Using XPath in Message Assignment).

 

 

 

I have found that the XPath queries can only be done against a Message and the results can be set to a Message, XML Document or other orchestration variables.  XPath queries can also be executed against untyped messages.  That is, a Message that is of type System.Xml.XmlDocument.

 

 

 

CRITICAL: BizTalk xpath can be used to both read values and set values inside your Message.  To set values in your message, you need to be inside a Message Construct shape.

 

 

 

Here are some of the things you can do with xpath and how to do them:

 

– Set a single values inside a Message using xpath

 

 xpath(SingleXML, “//LineTotal”) = nLineTotal;

 

 

 

– Extract a single piece of data out of a Message

 

 sCustomer = xpath(InXML,”string(//Customer)”);

 

 

 

– Extract a single node out of a large XML Document and assign it to a message or variable

 

 sXPath = System.String.Format(“//Item[{0}]”,nCount);

 xDoc = xpath(InXML, sXPath);

 

 

 

– Count the number of nodes or occurrences of something inside your message

 

 nNumberItems = System.Convert.ToInt32(xpath(InXML, “count(//Item)”));

 

 

A great resource for xpath functions and expressions is the W3Schools.

 

 

 

I have put together a sample that shows several different xpath uses inside the Orchestration.  This sample takes in an Order, calculates the total per line, sends out each line item as a single message, and sends out the whole order with an order total.  Note that the Item nodes are not updated on the Output document, only on the single documents.

 

 

 

DOWNLOAD: XPath Sample

 

 

 

The de-batching approach is based on Darren Jefford’s Blog about Manual Message Splitting.  Make sure you check it out and download his sample as well.

Accessing Message Data Inside an Orchestration using XPath

BizTalk 2004 allows simple access to data inside an Orchestration by using Xpath. This can be used to read and write data as well as total message assignment. This sample shows different ways to access data using Xpath inside the Orchestration.

This sample will work for both BizTalk 2004 and BizTalk 2006.

Get more information from the original blog post on this topic: https://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2004/10/25/using-xpath-inside-biztalk-orchestrations.aspx