Thursday, 20 October 2016

Maps For Every Journey

In general the job of transforming one message type to another requires a map.

Message A > MapA2B > MessageB

This is cool if you have a simple scenario that always happens, day in, day out. But what if you have mapping rules which change depending on properties not held in your source message?

Well, BizTalk has a handy feature to help. It is possible to invoke a transformation from two different shapes - the good old Transform shape and the Expression shape. And, as I mentioned in a previous blog article, expression shapes can have complex flow logic such as IF statements. That means you can invoke any map you like.

if (condition)
{
       MapType = Type.GetType("NameSpace1.Map1, AssemblyName1, Version=1.0.0.0,Culture=neutral, PublicKeyToken=111111111111");
}
else
{
       MapType = Type.GetType("NameSpace2.Map2, AssemblyName2, Version=1.0.0.0,Culture=neutral, PublicKeyToken=111111111111");
}
// use the map type in the transform
construct _responseMessage
{
       transform (responseMessage.x1, _responseMessage.x2) = MapType(requestMessage.s1, _requestMessage.s2);
}

// or you can use the fully-qualified map name in the transform
construct _responseMessage
{
       transform (_responseMessage.x1, _responseMessage.x2) = NameSpace.MapName (requestMessage.s1, _requestMessage.s2);
}

Fun eh?!

(originally posted by Dave B)

No comments:

Post a Comment