Geeks With Blogs
Evan Koch Musings on BizTalk Server and SQL Server

Using multi-part messages is first in Marty Wasznicky’s article 8 Tips and Tricks For Better BizTalk Programming
so I thought I might demonstrate this technique in more depth.  My experience with multi-part messages has been when I want to define a single message to pass among loosely coupled orchestrations that contains all the messages associated with the initial loan request.  This post also uses code from some of my previous posts, so some of it should look familiar.

Multi-part message types can be defined within BizTalk so that a message can contain parts associated with various schemas.  For this example, we’ll use a multi-part message to contain the initial loan request and the mortgage documents request.  Below is a diagram of the process.


In the main orchestration that calls each task we’ll create the multi-part message and pass it into the other orchestrations as they are called.

The multi-part message is defined so that one of the message parts follows the LoanRequest schema while the second part follows the PreparedLoan schema.  I’ve defined the LoanRequest part as the message body which will come into play in the ArchiveLoan orchestration.

Each part of the multi-part message can be assigned separately within a Message Assignment shape.  In this case I’m setting the LoanRequest equal to the initial message and the PreparedLoan equal to a XML variable that contains an unpopulated MortgageDocuments node.

 In the Prepare Loan orchestration we’ll pass the loan request through a policy to generate the documents for the mortgage.  Since the message is being passed by reference, we have no need for output parameters – the main orchestration’s copy of the multi-part message is being updated within the Prepare Loan orchestration.  To determine which mortgage documents are needed, the loan is passed through a rule policy.


The rule policy needs instances of both the LoanRequest and PreparedLoan schema to run, though we’re able to pass in the various parts of the multi-part message to satisfy this requirement.


In the GenerateLoanDocuments orchestration, we only want to send the contents of the PreparedLoan message part to the SendGenerateLoanDocuments port. 


For the purposes of associating the Send shape with a message, we’re not able to consider each part of the multi-part message separately, so we create a message of the PreparedLoan type first and assign it to be the same as the multi-part message’s PreparedLoan part.


And finally we have the ArchiveLoan orchestration.  In this instance we send the multi-part message to the Send port, but what is actually written to the file system might be different than what one would expect: while the entire multi-part message is sent, only the message body (in this case, the LoanRequest message part) is written to the file system.


Source code for this example can be found here.

Posted on Wednesday, October 31, 2007 9:41 AM | Back to top

Comments on this post: Multi-part Messages

# re: Multi-part Messages
Requesting Gravatar...

I am facing a problem, i added a web reference to a BizTlak orchestration, and i got the web methods, Schemas etc, the issue is i one of the request schemas is a multi part i am trying to create a message of this type but BizTalk desinger cannot find the meesge type

Can u help me ?
Left by Wael on Jun 09, 2008 3:53 AM

Your comment:
 (will show your gravatar)

Copyright © Evan Koch | Powered by: