How to: Apply mapping on send and receive ports
Problem:
I was having trouble routing a message that was extracted for an email by my own custom pipeline component
(also see How to: Extract email attachements using a custom pipeline component).
A flatfile was placed in a filelocation and had to be converted to XML and mapped from a scanorder to a weborder format so Axapta could pick it up.
So first I discovered how mapping on ports works.
After I've learned to understand this mechanism I went on to How to: Transform Text Files into XML.
Mapping in BizTalk is a transformation from one XML to an other XML document. This transformation is done with the help of the underlying XSLT (Extensible Stylesheet Language Tranformation). A map is a graphical representation of the XSLT.
A map on a receive port will execute only after the pipeline completes it's work, and on send ports before the pipeline executes.
A receive port can have multiple maps (with different source schema's) on it, because a receive port can have more than receive location.
Thus, a receive port can receive messages from different formats.
Depending on the type of message, the appropiate map is applied to it, and the message is dropped into the messagebox.
To have a map applied to a message, it's message type must be known. The Messagetype promotion is done by the pipeline's disassembler components.
A map gets executed when it has the source schema identified and matches against the message comming out of the pipeline.
Multiple maps on one port:
Although it won't work as expected, you can apply multiple maps with the same source schema on a receive port;
Item -> Item_To_Product -> Product
Item -> Item_To_Article -> Article
Item -> Item_To_Artifact -> Artifact
Only one of these maps will be executed and it is unpredictable wich one will be chosen.
To achieve the convertion of an incomming message into many messages, you can implement different send ports with the specific maps.
Chain Mappings:
If you want to chain mappings;
Item -> Item_To_Product -> Product
Product -> Product_To_Article -> Article
The best way to do this is to apply the first mapping on the receive port and the second one on the send port.
Mapping on a PassTru Pipeline:
Maps won't be executed when you use a PassTru Pipeline, for maps can't be applied to messages without a messagetype.
The messageType of a message is determined bij a Disassembler component in a pipeline; a PassTru pipeline has no components and doesn't process messages.
EndPoint Manager:
It is the endpoint managers (EPM) responsibility to look after the messages while they journey through the adapter, pipeline and maps. The endpoint manager is the service responsible for managing send and receive ports and acts as intermediary between ports and the messagebox.
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.
Maak jouw eigen website met JouwWeb