If you're calling .NET components from BizTalk Server 2004 orchestrations, then chances are sooner or later you'll want to pass in complete messages as arguments. Doing it is actually pretty easy.

One way to do this is to get your component to accept an XmlDocument instance. This works right away because ultimately, the BizTalk message is just an XmlDocument instance with a lot of goo on top, and so BizTalk knows hows to convert right away from and to an XmlDocument.

However, you might actually want more control over this. So, one way to work things is to have your components accept an instance of Microsoft.XLANGs.BaseTypes.XLANGPart, as it has a few useful methods and properties. For example, you can access the document's schema thorugh the XmlSchema property.

One pretty useful method in XLANGPart is the RetriveAs() method, which allows you to get a copy of the message into a representation you can deal with. Obviously, XML related types work right away (XmlNode, XmlDocument, and a few others, but not XmlReader), but you can specify any other type that is Xml-Serialization-compatible with the message schema.

Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.