Orchestration - Handle SOAP Exception and deal with Suspended (resumable) messages

Posted at: 5/16/2007 at 6:52 PM by saravana

The main reason for this blog post is due to this newsgroup post

Download Sample from here.

Step #1: Catching SOAP Exception:

Whenever you call a Web service it's a good practice to handle the SOAP exception specifically rather than just leaving the orchestration to throw an un-handled exception which will result in orchestration service instance and all the referenced message instances being suspended. As shown in the following Orchestration diagram, handling a  SOAP exception is straight forward. Place your "Send" shape inside a "Scope" and add an Exception Handler with "Exception Object Type" configured to System.Web.Services.Protocols.SoapException (You need to add reference to "System.Web.Services"). The "Message Assignment" shape  inside the catch block got this simple statement

SOAP_EXCEPTION_MESSAGE = soapException.Detail.InnerXml;

Where SOAP_EXCEPTION_MESSAGE is an Orchestration message of type System.String and soapException is the "Exception object name" we assigned for the exception handler. So, with the following setup, whenever there is an exception a message similar to the one shown below will be generated and send across the wire with configured adapter (FILE, SMTP etc).

<string><ns0:NACK Type="NACK" xmlns:ns0="http://schema.microsoft.com/BizTalk/2003/NACKMessage.xsd"><NAckID>{2DA185D7-40E7-4279-9F6E-ADCEB6EF599B}</NAckID><ErrorCode>0xc0c01f07</ErrorCode><ErrorCategory>0</ErrorCategory><ErrorDescription>SoapException: System.Web.Services.Protocols.SoapException: Purposely raised this exception for testing at CustomerProcessing.Get500InternalSoapException(String yourName) </ErrorDescription></ns0:NACK></string>

Step #2: suspended(resumable) messages:

Even though you handled the SOAP exception using an exception handler in STEP #1, it's only going to complete the orchestration gracefully but it's going to leave the original request message you posted to the web services in a suspended(resumable) state. Bear in mind the SOAP exception will be raised inside the orchestration only after the send port has exhausted all the retries.  During this period the messaging instance and orchestration service instance will be in the dehydrated state as shown below.

After all the retries, the SOAP exception will be raised inside the orchestration and corresponding SOAP request message will be suspended with resumable state as shown below. This will help the administrator to either resume or terminate the message later.

 

But at some scenario we don't wont to leave the suspended (resumable) messages in the messagebox, instead move them to a different location (either to file system location or a remote server via HTTP etc, etc). Before BizTalk 2006 the only way to archive this behavior is by writing some WMI scripts, which is OK but doesn't really fit with the message flow infrastructure. But with BizTalk 2006 we can take advantage of "Failed Message routing" capability and make this task seamless.

All you have to do is, on your SOAP send port check the check box "Enable routing for failed messages" (as shown in the following figure) and also you can set optionally the "Retry Count" value to "0" if you want to raise the SOAP exception straight away.

Then configure a "Send Port"  (or an orchestration, if you want to do more business logic with the suspended messages) with following filter condition

ErrorReport.ErrorType == "FailedMessage"

ErrorReport.OutboundTransportLocation ==  http://localhost:47653/SOAPExceptionHandler.WebService/CustomerProcessing.asmx

The above filter condition will make sure you are dealing only with SOAP exception raised due to messages posted to that particular web service (CustomerProcessing.asmx). There are quite a bit of promoted properties that comes along with "ErrorReport" you can take advantage of to cater your situation as listed below.

  • Description
  • ErrorType
  • FailureCategory
  • FailureCode
  • InboundTransportLocation
  • MessageType
  • OutboundTransportLocation
  • ReceivePortName
  • RoutingFailureReportID
  • SendPortName

Related Reading:

http://blogs.conchango.com/matthall/archive/2005/07/28/1894.aspx

http://objectsharp.com/cs/blogs/matt/archive/2006/11/01/4110.aspx

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(35) | Comments RSS

Comments

Thursday, May 24, 2007 10:11 PM
Anonymous
Anonymous
I have a similar scenario except that I have exposed my orchestration as web service and I want to catch the exception from called web service, construct a fault message and send it back to my orchestrations receive response port exposed as web service.  In this case the call to the orchestration web service always timesout and the fault message gets suspended.  Do you have any other ideas.
Friday, June 15, 2007 2:06 PM
Anonymous
Anonymous
I have had the same problem. This describe my problem.

My Scenario:
I have published a schema as a web service. The orchestration that will handle an incoming message will in turn send a message to a web service and eventually return a response message back to the caller. If an exception occurs on the send port I want to be able to catch it and return a response containing information about the failure.

My Symptoms:
BizTalk will suspend my orchestration and also produce a routing failure, causing the calling web service to time-out.

“A response message for two-way receive port "<myPortName>" is being suspended as the messaging engine could not correlate the response to an existing request message. This usually happens when the host process has been recycled”

The routing failure is caused by a PersistenceException thrown by the XLANG engine and information about the error was found in the event log.

“The published message could not be routed because no subscribers were found.”

with the following additional information:

“Failed to publish (send) a message in the batch. This is usually because there is no one expecting to receive this message.  The error was The published message could not be routed because no subscribers were found.”

The Solution:
This behavior actually seems to be a bug in BizTalk. After a bit of research I came across this hot fix: support.microsoft.com/default.aspx" REL="nofollow">support.microsoft.com/default.aspx. The hot fix corrects an error in the ‘Btsmsgcore.dll’ for two-way SQL Adapters but it fixed my problem with the two-way SOAP adapter to.

Note:
The hot fix will only eliminate the routing failure. The orchestration will still be suspended in the message box after the response has been returned. This will need to be handled through enabling routing for failed messages.
Sunday, July 11, 2010 8:05 PM
payday loans
The supreme happiness in life is the conviction that we are loved.
Saturday, July 17, 2010 4:44 AM
Supra Vaider High
Good page. It's useful to study your blog. The information of your site is precisely excellent, and your blog design is Simple good. Also you can look me at http://www.supras.cc/supra-vaider-high-3/ and give some suggestion. Thanks.
Saturday, July 17, 2010 8:59 AM
Rerto Jordans
This site sounds amazing and appeals to the shoe addict in me. This site is indeed a value adding one。I was thinking about writing a post on this exact subject. Thank you.
Saturday, July 17, 2010 9:25 AM
data cleansing software
Its good things, keep share
Monday, July 19, 2010 1:47 AM
Supra TK Society
Fantastic article. It is actually an enjoy to study your site. The content among your blog is strictly splendid, and your blog structure is Simple nice. It seems not dazzled. So excellent.
Monday, July 26, 2010 1:06 PM
cash loans
Remember you will not always win. Some days, the most resourceful individual will taste defeat. But there is, in this case, always tomorrow - after you have done your best to achieve success today.
Tuesday, July 27, 2010 10:06 AM
Jordan 5
I have read your article, I like it very much!It's so cool~!  If you have more interesting things, please log in  http:// www.cheapjordans.cc/.../ and give me some advises.
Friday, July 30, 2010 8:17 AM
Retro Jordans
Rather enlightening and beneficial post. You've got good command within the topic and have explained in a incredibly nice way. Thanks for sharing.
Saturday, July 31, 2010 1:45 AM
Jordan 1
If you love somebody, set them free. If they return, they were always yours. If they don’t, they never were. I recommend you to skim through our website. http://www.airjordan.cc/air-jordan-1-1/ You can choose best shoes to your lover. Best wishes for you.
Monday, August 02, 2010 3:02 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 3:58 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
Thursday, August 05, 2010 1:44 AM
Seattle Limos
I like the blog, but could not find how to subscribe to receive the updates by email.
Saturday, August 07, 2010 3:52 PM
Cam Girls
So much spirit, I feel as though you've definitely hit the nail on the head.  Good job with this.  Please keep brining us more because we need more of your type of blogger.
Saturday, August 07, 2010 4:19 PM
Sex Chat
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 7:52 AM
hypotheek
Hypotheken? Heel veel hypotheek informatie: verschillende hypotheekvormen, hypotheekrentes, nationale hypotheek garantie, hoe een hypotheek te vergelijken.
Tuesday, August 10, 2010 7:55 AM
hypotheek
Hypotheken? Heel veel hypotheek informatie: verschillende hypotheekvormen, hypotheekrentes, nationale hypotheek garantie, hoe een hypotheek te vergelijken.
Wednesday, August 11, 2010 3:51 AM
Jordan Hydro
You are just brilliant, do you know this?
http://www.nikeairjordan.cc/jordan-hydro-57/
Wednesday, August 11, 2010 8:10 AM
AJF 20
All of us have hobbies. And our hobbies are changing all the time. I used to listen to music. Because I thought it could make me relaxed and happy. But now I don't enjoy it. I am interested in collecting stamps. These old stamps, some of them are of great value. I think it's very interesting.
http://www.cheapjordans.cc/nike-jordan-ajf20-37/
Wednesday, August 11, 2010 8:51 AM
Jordan 5
Recently I have made an investigation among 100 students of Senior.One in our school.About 45 precent students go to school without breakfast. While 35 percent students do not treat breakfast seriously.Only 20 percent students have enough breakfast with nutrition every morning. In fact breakfast is very important. It can make you have good member, and good judgement, and make you in good heip. So every student should start their day with a regular breakfast.
http://www.cheapjordans.cc/nike-jordan-5-v-7/
Wednesday, August 11, 2010 9:25 AM
Jordan 6
Recently, I find early rising is very good to me. it helps to keep me fit. We all need fresh air. Besides, by taking morning exercises I can improve my health. Early rising can also give me enough time to get ready for our work. So from now on I like early rising very much.
http://www.cheapjordans.cc/nike-jordan-6-vi-8/
Thursday, August 12, 2010 1:33 AM
AJF 20
All of us have hobbies. And our hobbies are changing all the time. I used to listen to music. Because I thought it could make me relaxed and happy. But now I don't enjoy it. I am interested in collecting stamps. These old stamps, some of them are of great value. I think it's very interesting.
http://www.cheapjordans.cc/nike-jordan-ajf20-37/
Thursday, August 12, 2010 2:56 AM
Jordan Retro 5
I love a boy mang years ago.. but now we never talk with each other ..So I hope everybody  read my passage can know a few things ,,we are students , we should try our best to study.Everything except study is useless ,Maybe sometimes you  will meet a boy (girl) ,you should keep distance for her and  him .It's good for you and him(her).
http://www.cheapjordans.cc/nike-jordan-5-v-7/
Thursday, August 12, 2010 3:22 AM
Jordan Retro 6
Opportunity is one of the elements of success. But opportunities don't come often. And not all the opportunities can certainly lead to success. Moreover, opportunities are usually disguised as hard work; therefore most people don't recognize them. So if you want to achieve something, you must make efforts and get prepared. Otherwise, you will take no advantage of opportunities when they come to you. In my opinion,  there are plenty of opportunities for everyone in our society, but only those who have made enough preparations and are highly talented can make use of them to achieve their purpose.
http://www.cheapjordans.cc/nike-jordan-6-vi-8/
Thursday, August 12, 2010 4:38 AM
Creative Recreation
What makes life worth living? There are many possible answers to this question. But these things would not make life worth living, unless we were able to enjoy them. Whether or not we can enjoy these things depends on the emotions.
http://www.sneakers4sales.com/
Thursday, August 12, 2010 7:13 AM
Jordan 11
Rumor is the most primitive way of spreading stories—by passing them on from mouth to mouth. Pessimistic rumors about defeat and disasters show that the people who repeat them are worried and anxious. Optimistic rumors about production record or peace bring about confidence---and often overconfidence.
http://www.airjordan.cc/air-jordan-11-44/
Thursday, August 12, 2010 7:27 AM
Nike Air Max  90
Science is hard to study.One of the reason is that there are so many questions without answers.Much of sciece involves asking questions, and then studying and doing research to try to find the answers.Some questions have been studied by research scientists for many years,and the answers are still not known.However,scientists are slowly but surely able to answer more and more questions about life,and these answers change our lives and also explain them.
http://www.airmaxs.net/
Thursday, August 12, 2010 8:25 AM
Nike Air Max  90
Science is hard to study.One of the reason is that there are so many questions without answers.Much of sciece involves asking questions, and then studying and doing research to try to find the answers.Some questions have been studied by research scientists for many years,and the answers are still not known.However,scientists are slowly but surely able to answer more and more questions about life,and these answers change our lives and also explain them.
http://www.airmaxs.net/
Friday, August 13, 2010 7:34 AM
Retro Jordans
Thanks for posting this topic. I visit your site every once in a while and I just have to say that I'm so like your post!
Friday, August 13, 2010 8:01 AM
Nike Sb Blazer Low
This article is precise and justify the time it will consume while reading it. I will recommend every one searching this topic must have a look on this post. It has all the key points about the topic and covers all the aspects related to the topic.
Thursday, August 19, 2010 6:28 AM
Mens Engagement Rings
Excellent source of information. I'm browsing through your blog and found some other great posts!
Friday, August 20, 2010 3:36 AM
Lange & Sohne Watches
<p>Thanks so much for posting these, they are fantastic! So bummed I missed what looks like a truly unique evening.Said by <a href="http://www.obwatches.com/">Breitling Watches</a>. <br>
</p>
Saturday, August 21, 2010 7:07 AM
Retro Jordans
I see your site which look intriguing and worth a read. Keep the good work up i will add you to my favoroties!
Wednesday, August 25, 2010 4:24 PM
Cholesterol Lowering Foods
Excellent source of information. I'm browsing through your blog and found some other great posts!

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading