Executing BizTalk map in pipeline with arguments

While its possibility to send in arguments that can be use in an xsl transformation with XslTransform or XslCompiledTransform, it is not built in into BizTalk.

Why would you like to use arguments? For example in some situations we would like to use the information that exists in the message context or maybe we would like to add other information that could be specified in the pipeline and then used in the map.

So to be able to add arguments to a BizTalk map it needs to be run in a custom pipeline component, you could of course use some tricks in a orchestration but then it would be tricky to switch map if necessary and i try to stay away from orchestration as much as possible.

To be able to do it in a streaming fashion i have used a BizTalk class named BTSXslTransform that also better helps in transforming large files.

It is possible to add a parameter directly in a map but it requires a little trick so I have opted to add an object named Context through the AddExtensionObject method instead.

 

XsltArgumentsList

The Context class contains an Add method which inthis pieline component is used to add the information from the message context plus the messageId that is not in the context.

The Read method later lets you retrieve the information from the map.

The object must be linked to a namespace that exists in the xslt stylesheet. As it is a little bit difficult to add custom namespaces to a regular BizTalk map i have used an already existing namespace.

As you can see from the picture above i have used the namespace http://www.w3.org/1999/XSL/Transform which always is attached to the prefix xsl in BizTalk maps. Strangely it seams it is not possible to use this namespace in vs 2013, but it works in vs 2010. For vs 2013 i used the namespace for msxsl and that worked.

This enables us to use xslt markup like <xsl:value-of select=”xsl:Read(‘MessageID’)” />.

or like this

This enables us to use xslt markup like <xsl:value-of select=”xsl:Read(‘Company’,’http://my.company.namespace&#8217;)” />.

So if you dont specify a namespace, http://schemas.microsoft.com/BizTalk/2003/system-properties is used.

As this information is not available when you are testing the map in visual studio you must check if the function is available, the xslt functin ,function-available, is used to check for existance of a method .

 

function-available

The pipeline component has only one property named MapName where you specify the full name of the BizTalk map.

The full name is a combination of the name of the map and its assembly in the format name + comma + space + assembly like BizTalk.PipelineComponents.Test.Schemas.Schema1_to_Schema2, BizTalk.PipelineComponents.Test.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58eb6bc3e5e6e5db.

The information can be retrieved from the property page of the of the map in BizTalk administration console.

 

BizTalk map

It’s also possible to add multiple maps in a piped format which make it possible to handle multiple input files.

Example input for multiple files.

BizTalk.PipelineComponents.Test.Schemas.Schema1_to_Schema2, BizTalk.PipelineComponents.Test.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58eb6bc3e5e6e5db|BizTalk.PipelineComponents.Test.Schemas.Schema1b_to_Schema2, BizTalk.PipelineComponents.Test.Schemas, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58eb6bc3e5e6e5db”;

The pipeline component will automatically find the first map that matches the incomming message just like the regular BizTalk functionality.

I found a bug in this solution, as it was not possible to have shemas in another assembly then the assembly that the map was created in.

I fixed this and improved from my previous version in that it uses TransformMetaData class to indentify target schema and target assembly which i use to promote MessageTypeand SchemaStringName.

If you find this interesting just download the code and play around with it. I welcome any ideas to improve the solution.

Download code:BizTalk.PipelineComponent.XSLTransform

One thought on “Executing BizTalk map in pipeline with arguments

  1. Pingback: BizTalk enrichment pattern without Orchestration | fernandodosanjos

Leave a comment