Introduction

BizTalk being a Message broker at its core, mapping plays a vital role. Mapping in BizTalk is a transformation from one XML document to another XML document. And this transformation is done with the help of underlying XSLT (Extensible Stylesheet Language Transformation). And Map is a graphical representation of the XSLT. Thus Maps in BizTalk only accept XML and result out XML. 

Understanding the concept with examples

Maps can be used on ports as well as in an orchestration. Maps in orchestration can be used anywhere in the flow, but on the ports it has fixed place but is optional.  On Receive Port it will execute only after pipeline completes its work and on Send Port before pipeline executes.

There are scenarios wherein mapping is to be done between many to one  or one to many etc. And it is possible to do that, but there are some restrictions. Such maps can’t be applied on the ports but can be leveraged in Orchestration.

Likewise, there are some restrictions on the usage of map on ports, and this article intends to showcase them with scenario/question based examples.

A Receive port can have many maps on it, and it is tied to the fact that a Receive Port can have more than one Receive Location, which means receiving messages in multiple formats. And depending upon the type of message, appropriate map is applied to it and the message is dropped into MessageBox. Thus to have Map applied to the message, its message type should be known and that is done by pipeline having disassembler components.  

Is the Map chaining possible on the Port Level?

For this scenario, we will consider  following maps

  1. Item to Product
  2. Product to Article

Wherein first map accepts the item message and transforms it to product message and second map accepts product message and transforms it to article message. Can we have both maps on the same port?

Yes, you can. But map chaining will not take place on the same port as the only map which gets executed is which has source schema  identified and match against the message coming out of pipeline. And after that EPM hands over the message to MessageAgent  . To achieve map chaining for above scenario first map can be applied on receive port and the other on send port (Intermediate message will go through MessageBox). 

Can we have multiple maps with same source schema?

For this scenario, we will consider following maps

  1. Item to Product  
  2. Item to Article
  3. Item to Artifact

Yes we can have maps with same source without any error as multiple maps are supported on port, but only one of them will be executed and its unpredictable which one will be the chosen one.

To implement such scenario wherein  incoming message is to be converted into many, having send port with the specific map can be done.



Can we have map with same source and destination schema?

We can have map with same source and same destination as selection of map is based on the source message type and no consideration for destination schema  (provided it serves a purpose, example converting the date from ISO to Julian format, rest all incoming data is unchanged). 



Does map executes when PassThru Pipeline is used?

We can have maps associated with a Port using Passthru pipeline, but map won’t be executed. The reason being, maps can’t be applied to Untyped Messages and as PassThru does no processing on message, no message type available as MessageType promotion is part of pipeline processing.

Who is responsible for selecting Map?

It’s the EPMs (End point Manager) responsibility to look after the message while its journey from Adapter to Pipelines (And Maps if present) on Receive Port and from Maps (if present, else pipeline) to Adapter on Send Port.


It executes the pipeline and maps. After the message exits pipeline, EPM checks for the MessageType and picks Map which has a source schema matching to the message and executes it. And after that message is submitted to Message Agent.

Conclusion

Through this article, with the help of scenarios/example we saw how maps are selected and executed at port level.

The first thing when considering having map applied on Receive port is to have a pipeline with Disassembler component as it’s required to promote MessageType property and this is used to select the Map.

In a scenario where data is received in various format, canonical design pattern should be used with multiple maps at Receive port .

In a scenario where data is to be transformed to specific format , then dedicated map should be configured at the Send port.



Author

Maheshkumar S Tiwari
http://tech-findings.blogspot.in/

See Also

Read suggested related topics:

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.