In BizTalk you construct an instance of a message either:
- With a transform (the ideal way) which means creating a map. When the transform is executed inside your construct shape it will create an instance of the message, or
- By constructing it in an assignment which is similar to how you are doing it in your sample above, except that it is probably easier doing it with a static helper method. If you need to pass Biztalk messages as arguments to the method use the
XLANGMessage type found in Microsoft.XLANGs.BaseTypes library. You will first need to generate a .net representation of your message schema (using xsd.exe or svcutil.exe) so that you can deserialize the message using XLANGPart.RetrieveAs(typeOf(xxx)). To pass your messages out then you can make your .net method return type XmlDocument and as long as the XML maps to a message schema, BizTalk will take care of the conversion for you.
Hope this helps.
can you tell me more details about how to construct msg in an
assignment
It's similar to what you have except you use a XmlDocument type and BizTalk will do an implicit cast for you.
Let's say you have a schema called SimRequest.xsd and you have created an orchestration message of this type called MySimRequestMessage.
You need to define a variable of type System.Xml.XmlDocument to hold the XML, which we will call xmlDocSimRequest.
Then in your assignment shape:
xmlDocSimRequest = new System.Xml.XmlDocument();
xmlDocSimRequest.LoadXml("<SimRequest xmlns='http://blahblah'>...some data here</SimRequest>");
// Cast to your message - it's as simple as
MySimRequestMessage = xmlDocSimRequest;
To generate the XML you can right click on your schema file in visual studio and select "Generate Instance", which will generate you a basic XML file which can act as a starting point. Note: To use the above method you will need to replace all double quotes with single quotes in the XML you use.