Stephen W. Thomas BizTalk Blog

100% Pure BizTalk
posts - 132, comments - 146, trackbacks - 438

My Links

News

Subscribe to my blog via:


Add to Google

Visit my website at:
www.BizTalkGurus.com

Archives

BizTalk 2004 Samples

BizTalk 2006 Samples

BizTalk Videos

BizTalk White Papers

BizTalkBlogs.com

Great BizTalk Blogs

Other Links

Dynamic Mapping (Transforms) in Biztalk Orchestrations

Dynamic mapping is the concept of specifying the map to be used for a transform at runtime inside the orchestration.  That means no Transform Shape is used to specify the map or input and output schemas. 

 

The help guide talks about dynamic mapping.  It is under the heading “Assigning to Transforms Dynamically”.  The help guide does not go into any detail as to when or why you would want to use dynamic mapping. In fact, the help guide makes the topic seems more complex then it really is.

 

Dynamic transforms can be used any time you have the same business process that needs to have the same or different message types sent into it but they need to have different maps based on some parameter. 

 

Example:  We are receiving a standard invoice from multiple locations for the same vendor.  The schema is exactly the same but the mapping of the vendor data to the base schema (date formats, currency conversion, etc.) is slightly different based on the vendor location.

 

Why not map on the Receive Port?  This is the most common solution to this type of scenario.  This uses document normalization to transform all your messages into the same type before it hits your business process.  This is a great solution but what about exceptions?

 

Exceptions in maps on the Receive Port can be hard to react to and even harder to orchestrate a retry or recovery process.  That is when mapping inside an Orchestration and Dynamic Maps come into play.

 

Calling maps inside an Orchestration provide a mechanism for exception handling, reprocess, and error notification.  Dynamic maps allow for greater flexibility by allowing countless maps to be called without a Transform Shape.

 

With dynamic maps, the map name can be stored inside an attribute in the message, read from the SSO, or read from some other custom component.  Then, it is as simple as creating a System.Type with the strong fully qualified map name.

 

This would look something like this:

tMapType = System.Type.GetType("DynamicMaps.Map_A, DynamicMaps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea");

 

construct Out_Xml

{

       transform (Out_Xml) = tMapType(In_Xml);

}

 

If the map is inside the same assembly as the Orchestration, the full strong name is not needed.  On that note, your maps usually are always inside a separate assembly...

 

It is important to point out this code needs to be inside an Expression Shape.  The help guide says a Message Assignment shape.  But, that will give a build error.  If you want to use the code inside a Message Assignment shape just remove the Construct key word.

 

Sounds too good to be true?  This does have one major drawback.  If the message type of the input message does not match the message type expected in the map you get a blank message contracted.  This can be seen in the sample below by running the RunMapType_ConstructBlank.xml message.  So, it is import to check for this after the map.

 

I have put together a sample the shows dynamically calling maps inside an Orchestration both in the same assembly and inside another assembly. 

 

Download: Dynamic Maps Inside an Orchestration

 

It is also common to see dynamic maps used with untyped messages (that is messages received as XmlDocuments).

 

Print | posted on Sunday, August 28, 2005 11:20 AM |

Feedback

Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Is there a similar concept for assigning dynamic shemas at runtime? How would a situation work where there are mutilple message types, each with a specific and very different schema, are arriving at a single recieve location such as a queue.
8/28/2005 4:18 PM | Eric Williams
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

I don’t know a way to assign a schema at runtime inside an Orchestation. In that case, I have treated the messages as Xml Documents. This does not affect mapping inside the Orchestration since the message type property is set on the context (assuming you use the Xml Pipeline). In this type of scenario, you could simple create and deploy all the schema and the pipeline will take care of the assigning a message type.

Would this work for you?

Stephen W. Thomas
8/29/2005 6:24 AM | Stephen W. Thomas
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Stephen - I POC'ed this a few weeks ago and your comment on using an Expression shape because of a build error with the Message Construct shape didn't ring a bell. I went back and looked at my code and I'm using a Message Construct shape. What build error are you getting with a Message Construct shape?

Great point on exceptions and receive port maps. I avoid maps in send ports too for the same reason.
8/29/2005 6:58 AM | AndyM
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Stephen,

Does your sample apply to BizTalk 2004, BizTalk 2006 or Both?

Raj
8/29/2005 7:09 AM | Rajinder Singh
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

What is the preffered way to check for a blank document. I tried xpath(..), but it fails if there is no root element.

Thanks,
craig
9/2/2005 7:31 AM | Craig Neuwirt
Gravatar

# BTS Diary 7 - WSS vs EntLib, Dynamic Maps

WSS vs Ent Lib : Here's something I found really interesting. In our dev workstations we hadnt installed...
9/3/2005 4:43 PM | Santosh Benjamin
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hello.

We set the resulting message to an Xml Document and then checked xDoc.HasChildNodes.

I would guess you could also pass the message out as an XLang Message to a .net component.

I’m sure there are other ways as well.

Stephen W. Thomas
9/7/2005 6:07 PM | Stephen W. Thomas
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hi Stephen,
I have found your article on dynmatic transforms to very helpful in the project that i am currently working on, But i do have a query regarding the use of multiple source schema's in your map defination, will the transform still work? I have tried by creating this map with the orchestration component and then adding the map to specific maping component, but only a blank message is created.

Cheers D
10/31/2005 7:58 AM | Damien McCartney
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hello.

It should still work. Usually when you get a blank message you have a namespace or document type mismatch. The map is expecting X and you are sending Y.

You might want to try it first with the Transform Shape – at least to see what it is expecting as input.

Stephen W. Thomas
10/31/2005 8:50 AM | Stephen W. Thomas
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hi,
Basically the code
construct Out_Xml

{

transform (Out_Xml) = tMapType(In_Xml);

}
is an XLANGs representation of a Transform shape.So,Is there any significant reason for writting the code inside the expression shape ?Or the same logic can be implemented by using different transform shapes for calling different maps?
5/22/2006 2:11 AM | Sulaiman A
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

You could have different transform shapes if you only had a few different types of messages and maps.

In that case, you would also need to have your messages defined as typed messages. So, you would not easily be able to receive multiple message types inside a single Orchestration.

Plus, if you had say 100 different maps you would end up with a lot of shape. And adding a new map would mean having to edit the Orchestration to add a new shape.

Stephen W. Thomas
5/22/2006 10:10 AM | Stephen W. Thomas
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hi ,

Thanks a lot.
I have another question related to editing <Any> element inside the orchestration.
I have an Error.xsd schema with structure as,
<Error>
<ErrorDetails>
<ErrorId></ErrorId>
<ErrorDesc></ErrorDesc>
</ErrorDetails>
<Any>
</Error>

In this <ErrorId> & <ErrorDesc> are distinguished fields.

I am trying to construct the Error Message inside an orchestration using Construct shape but without map.
Since the <ErrorId> & <ErrorDesc> are distinguished ,I am directly assigning values to them .But i want to assign a different messae to the <Any> element.
Any idea how to access and set values of the <Any> element of a schema inside orchestration ?

Many Thanks,
Sulaiman A
5/23/2006 1:36 AM | Sulaiman A
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hello,

I ran into some difficulty with the Custom Pipeline that I haven't been able to figure out. The following errors were in the Windows Server 2003 event log after dropping "A-RunMapTypeA.xml" into the C:\DynamicMaps\In folder...

Error #1:
There was a failure executing the receive pipeline: "DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea" Source: "Unknown " Receive Port: "DynamicMaps" URI: "C:\DynamicMaps\In\A*.xml" Reason: Failed to get pipeline: DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea. Please verify that the pipeline strong name is correct and that the pipeline assembly is in the GAC.

Error #2:
A message received by adapter "FILE" on receive location "PartnerA-File" with URI "C:\DynamicMaps\In\A*.xml" is suspended.

Error details: There was a failure executing the receive pipeline: "DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea" Source: "Unknown " Receive Port: "DynamicMaps" URI: "C:\DynamicMaps\In\A*.xml" Reason: Failed to get pipeline: DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea. Please verify that the pipeline strong name is correct and that the pipeline assembly is in the GAC.

Using "sn -v DynamicMaps.CustomPipeline.SetTransform.dll", I have observed that the assembly is in the GAC and valid. Can you give me a clue as to what this problem might be? Thanks for your help.

-Kris
6/23/2006 5:44 AM | Kris
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

I am having exactly the same problem since I have updated my custom pipeline. Dit anyone find a solution yet??

Cheers, Bart
10/19/2006 3:01 AM | Bart Thijs
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Unable to GAC the custom pipeline dll.
I have built the custom pipeline project and the dll exists in the folder in the BizTalk pipeline components. When I GAC the dll, It says Unkonwn failure. Please help
10/27/2006 3:27 PM | Lakshmi
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

I guess the DLL name in the error message and the GACed dll name does not match.
10/30/2006 1:35 PM | Lakshmi
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

I ran into some difficulty with the Custom Pipeline that I haven't been able to figure out. The following errors were in the Windows Server 2003 event log after dropping "A-RunMapTypeA.xml" into the C:\DynamicMaps\In folder...

Error #1:
There was a failure executing the receive pipeline: "DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea" Source: "Unknown " Receive Port: "DynamicMaps" URI: "C:\DynamicMaps\In\A*.xml" Reason: Failed to get pipeline: DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea. Please verify that the pipeline strong name is correct and that the pipeline assembly is in the GAC.


Stephen, Please help us to resolve this issue.
10/30/2006 2:32 PM | Naveen
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

I ran into some difficulty with the Custom Pipeline that I haven't been able to figure out. The following errors were in the Windows Server 2003 event log after dropping "A-RunMapTypeA.xml" into the C:\DynamicMaps\In folder...

Error #1:
There was a failure executing the receive pipeline: "DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea" Source: "Unknown " Receive Port: "DynamicMaps" URI: "C:\DynamicMaps\In\A*.xml" Reason: Failed to get pipeline: DynamicMaps.Pipelines.SetDynamicTransform, DynamicMaps.Pipelines, Version=1.0.0.0, Culture=neutral, PublicKeyToken=faed587cb93de4ea. Please verify that the pipeline strong name is correct and that the pipeline assembly is in the GAC.


Stephen, Please help us to resolve this issue.
11/13/2006 4:35 AM | Mohamed Zahra
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hi,
I have an issue where in i need to haved ynamic mapping to be done but , i need to have two schemas in the source side. for that map.
7/12/2007 9:44 AM | bindhudheer
Gravatar

# re: Dynamic Mapping (Transforms) in Biztalk Orchestrations

Hallo,
what about if I want to transform flatfile inside orchestration without convert in XML?

Thanks
Andrea
11/27/2007 4:32 PM | Andrea

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 4 and 5 and type the answer here:

Powered by: