Constructing a Message within an Orchestration from an existing XML String
pdamiani These last few days I’ve been working with the SQL Adapter for receiving messages in my orchestration and I’ve got stuck in a peculiar situation: one of the columns I was retrieving has an XML string as its value. The situation was that I wanted to create another message from that XML string after the reception of the SQL message.
In this post I’ll show how to create a message in an orchestration from an already created XML string.
In order to understand better the situation, let’s describe the scenario:
- Suppose we have a SQL Table with three columns, for example: Id (uniqueIdentifier), occursOn(DateTime), configXML (varchar).
- Using the Wizard, I created the schema for retrieving the rows from the SQL table.
- Once received the message, which involves the three columns mentioned above, I wanted to create a new message from within the orchestration using the configXML value received in the SQL message.
This can be achieved with the help of System.Xml.XmlDocument class. This class has a method called LoadXml( string xml ) which allows us to create an XmlDocument from an already created XML string. After loading the XML from the string, we can set this document to our message in Biztalk; this is possible because every message in Biztalk derives from XmlDocument.
Here are the steps to follow to construct a message from an already existing XML string:
1. Create the schema file for your already existing xml string
2. Add a message of the type created in step 1 to your orchestration
3. Add a variable of type System.Xml.XmlDocument to your orchestration
4. Add a construct shape in order to construct your message of step 2
5. Add an expression shape inside the construct shape with the following expression:
In this example, varXMLDoc is the variable created in step 3; MySQLMessage.configXML is the XML string previously received in another message; and MySecondMessage is the message created in step 2.
That’s it, hope this to be useful!
Posted in Biztalk Server 2004 & 2006 |