Creating BizTalk Messages using Inline XLANG/s Statements

One of the first thing a programmer moving to BizTalk encounters when authoring orchestrations is the confusion over what constitutes valid code inside an Expression or Assignment shape. Indeed, it takes a little while to understand the differences between C# and XLANG, the internal domain-specific language that has been designed to describe orchestrations in .odx files.

As a result, it is not very well known that it is perfectly possible to author portions of an orchestration directly using XLANG/s expressions and statements. For instance, it is perfectly possible to create a message in an orchestration, without using a Construct shape !

To illustrate this, imagine the following simple orchestration, that receives an incoming message and produces a resulting message. Nothing fancy here.

Notice that the preceding orchestration does not have a single Construct shape. Instead, the following code is pasted directly inside the Epression shape:

construct OutboundMessage {

    XmlDocument.LoadXml(
      @"<?xml version='1.0' standalone='yes' ?>
        <Root id='012345' xmlns='http://schemas.sample.org/BizTalk/2010/input' />
    ");

OutboundMessage = XmlDocument;
}

This code makes use of the XLANG/s construct statement that declares a scope in which it is possible to perform all operations pertaining to message construction. It is possible to create the message, add context properties or update distinguished properties.

Having said this, I don’t know of many valid reasons to use direct XLANG/s constructs in an orchestration ! Anyhow, this shows that there’s always more than one way to skin a cat…

This entry was posted in BizTalk. Bookmark the permalink.