When .NET code makes more sense than adapters
In some scenarios, using BizTalk adapters is not the best option. For example, you may want to handle communication directly through .NET code instead.
Common development scenarios
In other cases, you might need to access multiple or recursive values from a message inside a helper class that supports an orchestration. Likewise, certain situations require complex transformations or message construction that are easier to implement in code than in a BizTalk map.
A simple and reusable approach
Although there are several ways to handle these scenarios, one approach stands out. You can use an XML Schema to generate a .NET class. This method is simple, effective, and works across all these use cases.
By doing so, you gain a quick and straightforward way to represent BizTalk messages as strongly typed .NET classes, making message handling and processing much easier.
📝 One-Minute Brief
Explains how BizTalk developers can generate a .NET class from an XML schema to simplify message handling, enable advanced processing, and perform transformations directly in C# code instead of BizTalk maps.
The easy way to generate classes that conform to a specific schema is to use the need to use the XML Schema Definition tool (Xsd.exe). You can do that by:
- Open a Developer Command Prompt for VS <edition>

- On the command prompt, navigate to the Schema folder and type:
- xsd /classes /language:CS Schema1.xsd
For complex schemas that import or include other schemas, you need to provide all the dependencies, for example:
- xsd /classes /language:CS Schema1.xsd Schema2.xsd
Now you will be able to import the C# class generated by the tool to your helper project, and the rest is simple!
On the Orchestration, you can create a variable that represents that class:
- On the property Type, select the <.NET Class…> and select the class that you created previously:

- From the Browse and Select .NET Type to reference, you need to select the proper assembly and the Type.
Then, by using C# code inside Message Assign or Expression Shape, you can serialize or deserialize an XML document into C# and vice versa in a simple and straightforward way:
//CONVERT MESSAGE INTO C# OBJECT
varPersonMsg = msgInput;
//CONVERT C# OBJECT INTO BIZTALK MESSAGE
msgOutput4 = varPersonMsg;
Or if we have a function in a helper class like:
public static XmlDocument MapPersons(Person person)
{
...
}
We can directly pass the message to the function without the need to create a variable:
msgOutput4 = Support.Mapping.MapPersons(msgInput);
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.