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

Posted at: 12/21/2006 at 7:25 PM by saravana

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

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: | |  Categories: BizTalk General
Actions: Email this article Email | Kick it! | DZone it! | Save to del.icio.us | Technorati Links
Post Information: Permanent LinkPermalink | CommentsComments(9) | Comments RSS

Comments

Friday, December 22, 2006 11:01 AM
Anonymous
Anonymous
Buy-not-build, dude ;) Remember what Chappell told us: your code's not a deliverable - it's a liability. Let the platform take care of it.
Friday, December 22, 2006 2:31 PM
Saravana Kumar
Sorry mate, I didn't get it..I haven't build anything here out of the platform....just submitted a message in a MIME format!!
Monday, February 26, 2007 12:32 PM
Richard
Great post (as always)! Have you tried this in production?
Monday, February 26, 2007 12:49 PM
Saravana Kumar
Hello Richard, I've written one more article related to Content based routing and SOAP adapter:
www.digitaldeposit.net/.../...om-biztalk-2006.html

This one is bit more complex than using MIME message, because we handcraft the multipart message inside the custom pipeline component. This is in production calling a WCF service.

Nandri!
Saravana
Monday, May 21, 2007 10:11 AM
Ramanath
Hi Saravana Kumar,
Ramanath here, I went through your MIME attachment document, but one thing I din't understand is how did you create that MIME message. Can you give me the full SOAP message, so that I can determine how to send the same message through JSP.
Monday, May 21, 2007 10:26 AM
Saravana Kumar
Hi Ramanath, I created this sample mime message using notepad, just copying and pasting stuff. But you can buy some third party software like http://www.chilkatsoft.com/dotNetSmime.asp if you are using .NET. I don't know what level of support you have in JAVA for handling MIME messages.

Cheers,
Saravana
Tuesday, May 29, 2007 1:34 PM
Ramanath
ok.. Thanks.
Monday, October 29, 2007 2:13 PM
Syed
Hi Saravan, can we use MIME on receive pipeline on Win64 enviornment?

Thank you.
Zeeshan.
Wednesday, August 20, 2008 1:26 PM
Sharad in
Sharad
Hi,

First of all a big THANK YOU for all the great help that you have provided to all of us with your articles on various topics.It is really appreciable.

I'm a newbie to Biztalk. I wanted to call a web service and so I had added reference to the web service but the XSD files for this web service are not generated. So, I decided to use Construct Message and Message Assignment shape to initialize my web request message from my incoming message data.(And then Send shape should send the Request Message to Request operation of web port.)

I'm trying to assign to my Web Request message in the message assignment shape with this expression:

WebRequest_doc.input_xml = InboundDoc.input_xml;

Where

WebRequest_doc is a message created in Orchestration View under messages with 'Message Type' pointing to request Type Name of web method. input_xml 's Object Type = Message part with Type = System.String and 'Message Body part = false'

And InboundDoc is a message created in Orchestration View under messages with following Schema

<?xml version="1.0" encoding="utf-16" ?>

- <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://EDMIntegrationSchema.DocID"" rel="nofollow">http://EDMIntegrationSchema.DocID"" rel="nofollow">http://EDMIntegrationSchema.DocID"" rel="nofollow">http://EDMIntegrationSchema.DocID" targetNamespace="http://EDMIntegrationSchema.DocID"" rel="nofollow">http://EDMIntegrationSchema.DocID"" rel="nofollow">http://EDMIntegrationSchema.DocID"" rel="nofollow">http://EDMIntegrationSchema.DocID" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="ForEDM">
- <xs:annotation>
- <xs:appinfo>
- <b:properties>
<b:property distinguished="true" xpath="/*[local-name()='ForEDM' and namespace-uri()='http://EDMIntegrationSchema.DocID']/*[local-name()='input_xml' and namespace-uri()='']" />
</b:properties>
</xs:appinfo>
</xs:annotation>
- <xs:complexType>
- <xs:sequence>
<xs:element name="input_xml" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

But this does not work and I get this exception: Inner exception: The part 'input_xml' of message 'WebRequest_doc' contained a null value at the end of the construct block.
How should I initialize the message part 'input_xml' ?

Should I use custom pipeline like your example to receive a multipart message and then do the processing in orchestration?

Thanks for your help in advance.
Regards,
Sharad

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading