Microsoft BizTalk ESB Toolkit includes a set of helper classes used by the other processes, services, and components in the toolkit. Because these helper classes are also public, you can use them in your own code as required. For example in a BizTalk Orchestration you can use the MapHelper class to perform transformations directly.

The TransformMessage method takes as parameters a string that contains the message to transform and a string that contains the fully qualified name of a map deployed in BizTalk. The method returns a string containing the transformed document.

The Transformation Web service from the ESB Toolkit enables external applications to submit a document to an ESB application and have it transformed using a deployed Microsoft BizTalk map.  But is it also possible to  call directly the MapHelper class from you own code? In order to test it I created an small Windows Form application that calls the MapHelper class.


The sample tool makes it very easy to execute a BizTalk map. It requires a XML file as input, the name of the assembly and the map name.


Changes v1.1

The new features from the BizTalk 2013 MapTester are now also available in the version for BizTalk 2010.

What's New For This Release:
- AssemblyPicker  (from Sander Nefs:
- A new wizard to create an envelope message to wrap multiple input messages.
- Custom MapHelper class to perform BizTalk transformations directly from .NET.
- Measure the execution time of the map.
- User experience changes.


How to test a map

First enter the Source file and the fully qualified name of the map and click on Test Map.


You can now also pick the BizTalk map from an assembly.


 The output is stored in a file and shown on the Result tab.


How the sample works

Code example to call the custom MapHelper class and how to measure the execution time of the map.

System.Xml.XmlDocument sourceDoc = new System.Xml.XmlDocument(); 
//Fully qualified name of the map deployed in BizTalk. 
string mapName = string.Format("{0},{1}", TestSettings.Name, TestSettings.Assembly);                 
string result = nullstring docSpec = nullstring messageType = null; 
//Measure Start 
long startTick = DateTime.Now.Ticks;                  
//This method takes as parameters a string that contains the message to transform and a  
//string that contains the fully qualified name of a map deployed in BizTalk.  
//The method returns a stream containing the transformed document. 
using (Stream stream = MapHelper.TransformMessageStream(sourceDoc.InnerXml, mapName, falseref docSpec, ref messageType)) 
    using (StreamReader reader = new StreamReader(stream)) 
        result = reader.ReadToEnd(); 
//Measure End 
long endTick = DateTime.Now.Ticks; 
long tick = endTick - startTick; 
long milliseconds = tick / TimeSpan.TicksPerMillisecond;

More Information

For more information on execute a BizTalk map from .NET, see: