MIME Message, SOAP Adapter, Web Service with multiple input arguments – BizTalk Messaging-Only (CBR) solution.

Published on : Dec 21, 2006

Category : BizTalk Server



In my previous post we have seen how you can call a web service which expects a single argument using SOAP adapter with a .NET proxy client in a BizTalk messaging only scenario (aka Content based routing) without using any orchestration. In Step 4 of my previous post I explained how the IBaseMessage from Biztalk is translated into corresponding Web Service arguments in the proxy class. Basically, when we submit the sample message (CustomerInfo) via a Receive Location, BizTalk creates an IBaseMessage as shown in the below figure and submits it into the Message Box, which is then routed to the SOAP Adapter send port (based on ReceivePortName Filter). Inside the SOAP Adapter the body part of the message (CustomerInfo) identified by the content-id is assigned to the web service argument CustomerInfo. Now the .NET client proxy got all the required parameters (only one in this example)to make the call to the web service. WebService Signature: ProductInfo GetProductInfo (CustomerInfo customer) IBaseMessage: Now, coming to our second web method definition as shown below, how are we going to construct the IBaseMessage. ProductInfo GetProductInfoByAccountNumber (CustomerInfo customer, int accountNumber) The IBaseMessage to call the above Web Method should be in the form as shown below: One easy way to generate the IBaseMessage shown above is by creating an orchestration, Adding a Web Reference to our web service, Assign the web method parameters as shown below inside a message assignment shape WS_REQUEST.accountNumber = 5; WS_REQUEST.CustomerInfo = CUSTOMER_INFO; and link to the web port. The final Orchestration will look like the one shown below. But, our goal is to call the web service without using any Orchestration. In order to archive this, all we need is a properly constructed IBaseMessage as shown in Figure 2. The method we are going to see here is making use of MIME Decoder pipeline component that comes out of the box and submitting a MIME message (as shown below) with multiple parts. 1. Create MIME Message MIME-Version: 1.0 Date: Wed 20 Dec 2006 00:12:58 +0000 Content-Type: multipart/related; boundary=”———MIME-digitaldeposit.net————-” ———–MIME-digitaldeposit.net————- MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-ID: CustomerInfo Content-Description: CustomerInfo Content-Type: text/xml; charset=”utf-8″ <CustomerInfo xmlns=”http://www.digitaldeposit.net/biztalk/samples/Customer”> <CustomerID>string</CustomerID> </CustomerInfo> ———–MIME-digitaldeposit.net————- MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-ID: accountNumber Content-Description: accountNumber Content-Type: text/xml; charset=”utf-8″ <?xml version=”1.0″?> <int>5</int> ———–MIME-digitaldeposit.net————— The MIME message shown above is quite straight forward, it has two parts. The first part contains our first web method argument CustomerInfo  and the second part contains our second web method argument accountNumber. The key aspect here is the Content-ID MIME header, which is used to identify the part and assign in to the web method argument in the SOAP Adapter. 2. Create a custom BizTalk Receive Pipeline with MIME Decoder. Create a custom receive pipeline, drop the MIME/SMIME decoder component in the Decode stage (there is no settings to change). Build and Deploy it . When the mime message is passed through the pipeline line eventually through the MIME/SMIME decoded a IBaseMessage (Multipart) will be constructed equivalent to the one shown in Figure 2, which is required for our web service call. 3. Configure the BizTalk Solution: Now configure the BizTalk solutions as shown in the below figure. Refer to previous post for details on each port configuration. We need to make two changes here, when compared to the previous post. On the Receive side change the pipeline from PassThru to MimeDecoder (our custom one), and select the appropriate web method on the SOAP Adapter configuration. Download the sample solution here which got all the required files to support this blog post. So, How did I construct the MIME Message Unfortunately there is no support in .NET to create MIME messages, I created the MIME message manually in Notepad, its not hard as you can see. Conclusion: The only change we made in comparison to our previous post is changed the receive pipeline and changed the message to MIME message. This sample helps to understand 2 important things. 1. How to call a Web Service with the help of a MIME message and BizTalk 2. Also, how to call a web service without using an orchestration. Nandri! Saravana