Geeks With Blogs
Koushal Deshpande kd
I have faced the issue of calling web service from BizTalk, where intermittently either service is not available or there is some problem in connecting the service. Service can return response error code which is other than HTTP 200 code ie. HTTP 400 or HTTP 500 code. BizTalk doesnt like it. Send port will treat as warning, write warning in event viewer and retries. But eventually if problem and error persists then error will be thrown from send port. This error will be received in Orchestration. 

You can set exception handler block to catch the exception i.e. System.Exception or System.EntryPointNotFoundException. You can handle the exception gracefully. But send port instance will get suspended. This will not go away unless manually terminated. Since the exception is thrown from send port and probably it is valid response, there is no point in resuming it too. If you try doing it, orchestration which had called the service has already handled exited since exception has been handled in exception handler block.
This scenario needs to be handled by a separate orchestration which we can call "SendPortExceptionHandler". This orchestration will have only one receive shape connected to receive port. It will receive message of type Raw Xml. A filter needs to be created like below:

ErrorReport.FailureCode Exists   And
ErrorReport.MessageType == schema_namespace#root_node


You can add multiple filters, so that all exceptions at send port will be handled by single orchestration.

-----------------------------------------------------------------------------------------------------------------------------

If we get exception say System.EntryPointNotFoundException and we want to handle this manually. We might get this error if end point is not available or network is down. Then we might want to suspend the orchestration and retry manually. For doing this, we need to add a loop. Add a scope in that loop. Catch the specific exception in that scope exception handler. Please see below:


In the first expression box we will initialize values for retry. 

// Set retry to true

ServiceRetry = true;
ServiceRetryCount = 0;


In the internal scope (Mule ESB Scope) I am catching System.EntryPointNotFoundException. You can add another exception handler block to throw other errors. In this block I am setting values as below:

// Set retry to true

ServiceRetry = true;
ServiceRetryCount = ServiceRetryCount + 1;

In decide shape I am checking if retry count ServiceRetryCount <= 3 then it suspends the flow else exception will thrown. It will create a finite number of retries and orchestration will exit gracefully.
In outer all other exceptions are caught and thrown back to the calling orchestration.

This way, we can handle service end point related and web exceptions in BizTalk.


Posted on Monday, March 6, 2017 3:36 PM BizTalk , Service End Point Exception , Web Exception , HTTP400 , HTTP500 , HTTP200 , There was no endpoint listening at , System.Net.WebException , This is often caused by an incorrect address or SOAP action. See InnerException , if present , for more details. Resource not found. , System.Net.WebException: The remote server returned an unexpected response: (400) BadRequest , System.Net.WebException: The remote server returned an unexpected response: (500) BadRequest | Back to top


Comments on this post: Handling Exception in calling Web Service, In BizTalk

# re: Handling Exception in calling Web Service, In BizTalk
Requesting Gravatar...
Hi! Thank you for the cool tips! I`m going to use them for my web service "college homework help online".
Left by Andrew Lowe on Mar 06, 2017 5:44 PM

# re: Handling Exception in calling Web Service, In BizTalk
Requesting Gravatar...
Good post..Zellmeonline
Left by Anu on Mar 14, 2017 10:13 AM

# re: Handling Exception in calling Web Service, In BizTalk
Requesting Gravatar...
Your post helped me to learn how to handle exceptions in calling web service. Since it is explained with a pictorial representation, the concept is very clear to me. If you provide its source code, then it will be very useful. modular home manufacturers
Left by Oshin on Mar 14, 2017 5:28 PM

# re: Handling Exception in calling Web Service, In BizTalk
Requesting Gravatar...
Hi Oshin,
I dont have a prototype which is working for implementation. I have used this in project. You try to implement this and let me know if you get stuck anywhere.
Left by koushal on Mar 14, 2017 7:17 PM

# BizTalk
Requesting Gravatar...
I didn't realize that people were actually still using BizTalk !
How do you like that XSLT message mapper ?
have you tried using VB to integrate CORBA or MFC ?
Left by Josh on Mar 17, 2017 8:24 PM

Your comment:
 (will show your gravatar)


Copyright © Koushal Deshpande | Powered by: GeeksWithBlogs.net