A random collection of epiphanies, thoughts and problem solutions pertaining to .NET and BizTalk.

Friday, December 24, 2004

Create a New Message Inside an Orchestration Without using an External Component

BizTalk documentation states: "You construct a message any time that you introduce a message into your orchestration, either by receiving it or by assigning values to a message variable. ... You can invoke a .NET class to create a message, assign one message to another, or use a transform to map certain values within a message to values within another message. Messages are also constructed by a receive action or when your orchestration accepts a message as a parameter."




It basically says this: To create a new message, you have these options:


  • Transform from an existing message

  • Assign the variables of an existing message

  • Assign an existing message or message part to the new message

  • Use an external .NET component to construct a new message





Sometime you want to create a simple empty message to start with. This message doesn't have an instance yet. You don't have an existing message to do the message transformation. You don't want to use the external component since it introduces one more layer of complexity. Now what can you do? Looks like you ran out of the options. AMOF, you could easily construct a new message right inside the orchestration by following these steps:




  • Add a System.Xml.XmlDocument variable to the documentation. Without losing generality, let's say its name is theXmlDoc

  • Add a message assignment shape

  • In the expression shape of the assignment shape, enter the following:

    theXmlDoc = new System.Xml.XmlDocument();
    theXmlDoc.LoadXml("<root xmlns=\"http://www.namespace.org\" />");
    newMessage = theXmlDoc;



Followers