Enterprise Integration Pattern Part -6- Envelope Wrapper

Sometimes batches are sent with common header information related to messages in the batch. This information is useful for routing purposes whereas the information is also useful for processing the messages. This information may or may not be useful to other client application or processes other than the process which is processing the message. Sometimes the header is preserved if the header is needed sometimes it is stripped off from the batch.

You can read more about Envelope Wrapper Integration pattern here.

Thinking and implementing in terms of BizTalk we have to consider the disassembler component properties specially the preserve header property. I have seen a lot of BizTalkers getting in trouble with the header information and they have no idea where the header goes once they specify the header schema and the document schema property in the disassembler component.

Following is the input flat file which I have used as an example. It contains two items for body schema and two items in the header schema. We will mainly focus on the header items and how to extract them separately and access them in a meaningful way.


First thing you notice and should implement is to set the preserve header property to true. With this the header schema value is promoted to the message context and it can be extracted in the orchestration. In the figure below you can also see two other properties HeaderValue1 and HeaderValue2 in the expression editor. These values are much more useful than just extracting the raw header schema value. The raw header value can be extracted by the XNORM.FlatFileHeaderDocument context property of the message.



Now to extract the fields separately from the header you have to create a property schema. In my case I have defined two header fields (HeaderField1 and HeaderField2).




After creating the property fields make sure to change the Property Schema Base property to MessageContextPropertyBase for each of the header fields.



Next step is to promote these fields from the header schema as shown below.




Now when the project is built and deployed we test the solution by placing the input file in the input folder. What we expect is the two header values in the variables which are written in the event log along with the raw header XML which you can see below.





In this way we can use the header values in a more meaningful way and even if we need we can route the message based on the header values. If you could see the output file the header items would be stripped off from the batch.

You can download this sample from the box.net widget available on the right of the page.

3 Responses to Enterprise Integration Pattern Part -6- Envelope Wrapper

  1. Very good article about the how to preserving the header of the incoming message. I have done one test in the my local biztalk server and it work well.

    Do you have any information about the capturing the events fired by the biztalk like due to exception biztalk stop functioning. I want to capture those events and send an notification email to me that something went wrong.

    If you find any information then please send it to my email.


  2. Vijay says:

    Abdul, I see your different design pattern posts, which were awesome. To be frank, i understood scatter gather pattern after reading your blog post. Keep up your good work and biztalking..

    If you find time and have knowledge on Biztalk sharepoint then please provide simple post on integrating biztalk with sharepoint for statemachine and sequential scenarios.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: