I might be stating the obvious in this post but it took me and my colleague quite a while before we found what we were doing wrong. We wanted to disassemble the body messages from an envelope message and promote a value from the envelope to each body message. Not exactly rocket science .
Lets take the following schema and corresponding message as example:
In this sample the value of the ‘FamilyNumber’ element from the envelope has to be promoted to the context of each body message. Ok, very easy…… we thought.
This can be done using build in BizTalk functionality. Create a property schema, promote the element from the envelope, use the default XmlReceive pipeline to promote the value from the envelope to each body message and done.
After the first test run We were very surprised to see that none of the context messages of the disassembled bodies contained the promoted value. It took an embarrassing long time before we found out that the element to promote needs to be before the body messages instead of after the body messages.
It makes sense because the XmlDisassembler component in the XmlReceive pipeline works in a streaming forward only manner. Each time a complete body message is read from the stream it is delivered to the message box (or next pipeline component). So when the stream reaches the element to promote the bodies have already been delivered to the message box. This is why their message context does not contain the promoted value.
Changing the schema to:
will do the trick.
Tagged: BizTalk, Pipelines
