Aug 232008

I’ve needed to cast my BizTalk message as a System.String in a couple of occasions so I’m going to put it here to remember how to do it.
1. Create a Variable of type System.Xml.XmlDocument (I’m calling it xml_Temp here)
2. Create a Variable of Type string (I’m calling it str_MessageAsString here)
3. In the expression shape insert the following code:

//Instantiate your xml_Temp System.Xml.XmlDocument
xml_Temp = new System.Xml.XmlDocument();
//Assign the message you want as a string to your new xml_Temp System.Xml.XmlDocument
xml_Temp = msg_YourOriginalMessage;
//Assign the .OuterXml property of your xml_Temp to your str_MessageAsString System.String
str_MessageAsString = xml_Temp.OuterXml;