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

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(27) | 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 India
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" targetNamespace="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
Wednesday, July 07, 2010 2:33 PM
ADDIO CELIBATO ROMA
Really interesting articles. I enjoyed reading it. Thanks for sharing a nice info
Saturday, July 10, 2010 11:47 AM
data cleansing
Hi admin, your web page's design is fancy and i like it. Your posts are great. Please continue this great work. Cheers!!
Wednesday, July 14, 2010 7:49 AM
Mac Software
Thanks for taking the time to share this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.
Monday, August 02, 2010 12:21 AM
lenen
Over de voor- en nadelen van het afsluiten van een lening zonder BKR-toetsing.
Monday, August 02, 2010 1:37 AM
lenen
Lenen zonder BKR toetsing gaat vandaag heel gemakkelijk. Binnen een paar uur geld lenen zonder BKR toetsing doet u hier, lees snel verder
Monday, August 02, 2010 3:05 AM
lenen
U wilt geld lenen zonder BKR toetsing? De opties hiervoor worden groter, kijk verder en ontdek hoe u wél geld kunt lenen, snel & eenvoudig.
Monday, August 02, 2010 3:38 AM
lenen
Over de voor- en nadelen van het afsluiten van een lening zonder BKR-toetsing.
Monday, August 02, 2010 4:39 AM
lenen
Lenen Zonder BKR Toetsing Lenen zonder BKR toetsing stijgt in populariteit op het Internet. Veel mensen met een zogeheten BKR notatie, die toch geld willen lenen zijn op zoek naar ...
Monday, August 02, 2010 11:11 AM
lenen
Over de voor- en nadelen van het afsluiten van een lening zonder BKR-toetsing.
Thursday, August 05, 2010 1:43 AM
Seattle Limos
The blog was absolutely fantastic! Lots of great information and inspiration, both of which we all need!
Saturday, August 07, 2010 3:51 PM
Nude Cam
Interesting read, thanks for helping keep me busy at work ;)
Saturday, August 07, 2010 4:19 PM
Nude Cam
I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.
Tuesday, August 10, 2010 12:18 AM
hypotheek
Hypotheek informatie, hypotheek aanvragen of afsluiten? Hypotheekrentes bekijken. Hypotheek aanbieders vergelijken, hypotheek vormen, bijkomende kosten,
Tuesday, August 10, 2010 12:28 AM
hypotheek
Hypotheken? Heel veel hypotheek informatie: verschillende hypotheekvormen, hypotheekrentes, nationale hypotheek garantie, hoe een hypotheek te vergelijken.
Tuesday, August 10, 2010 7:52 AM
hypotheek
Hoeveel kan ik lenen? (hypotheek). Wat worden mijn maandlasten? (hypotheek) ... Hoeveel hypotheek heb ik nodig? Hoe hoog is de boete die ik nu zou moeten
Tuesday, August 10, 2010 7:54 AM
hypotheek
Hypotheek informatie, hypotheek aanvragen of afsluiten? Hypotheekrentes bekijken. Hypotheek aanbieders vergelijken, hypotheek vormen, bijkomende kosten,
Tuesday, August 10, 2010 7:56 AM
hypotheek
Hypotheken? Heel veel hypotheek informatie: verschillende hypotheekvormen, hypotheekrentes, nationale hypotheek garantie, hoe een hypotheek te vergelijken.
Tuesday, August 10, 2010 7:58 AM
hypotheek
Hypotheek informatie, hypotheek aanvragen of afsluiten? Hypotheekrentes bekijken. Hypotheek aanbieders vergelijken, hypotheek vormen, bijkomende kosten,

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading