none
Handling Exception with Ports using WCF-Custom Adapter RRS feed

  • Question

  • Hello All,

    I have a requirement where, exceptions has to handled inside the existing orchestration. The Orchestration has many request response ports, to insert datas into databases. Sometimes there are issues in the incoming message which suspends the messages. All Exceptions are to be caught and send a notification with the attaching incoming message.

    I have read in some article, the exceptions in request response ports cannot be caught by DeliveryFailureException and to use Fault message. My doubt is the orchestration is having many request response ports, do I have to create fault messages in each port and have different catch blocks.

    I know,I am missing something in understanding.Any help with this is greatly appreciated.

    Thanks


    • Edited by vdha Wednesday, December 31, 2014 5:06 PM
    Wednesday, December 31, 2014 5:06 PM

Answers

  • Hi Vdha,

    Yes, Delivery notifications do not work with solicit-response transmission.

    When dealing with a WCF service, in general there are 3 types of exception you have to deal with:

    1. Exception when the WCF service is down.
    2. Standard SOAP fault (System.ServiceModel.FaultException)
    3. Type Fault exception, if the WCF implements a custom Fault.

    For exception when the WCF service is down, you can catching with exception with catch block (under a scope) with exception object type System.Exception.

    For standard SOAP fault you can handle by adding fault operation message added to the solicit-response port. (Right click the port and add a fault message).

    For typed fault exceptions from WCF service, for the fault is typed is exposed as a schema which is imported by BizTalk when you generated the metadata using Add generated items wizard.

    Check with your WCF service, if they send typed fault you need to handle the with fault message, otherwise you need to have standard SOAP fault by adding a standard fault message in port.

    When you have more service call and they don’t have typed fault, then you can except standard SOAP fault thrown when there is an issue (or System.Exception in case of transmission), it’s better to handle the standard fault message with System.Exception catch handler. Read the following article which handles these exceptions are handled. When you have a common generic exception handling process like sending the notification, then use "throw new System.Exception" in each of its scope and handle this thrown exception in a catch block which is common to the whole orchestration and construct the notification message and send the notification message in this common catch block. If I translate this into a try-catch block of c# code, this would look like this.. (This C# is just to give you an idea of how this can be constricted in orchestration using scope and catch blocks

    try
    {
    	try
    	{
    		call your WCF service1
    	}
    	catch(Exception ex1)
    	{
    		throw new Exception1
    	}
    	
    	try
    	{
    		call your WCF service2
    	}
    	catch(Exception ex2)
    	{
    		throw new Exception2
    	}
    	
    	try
    	{
    		call your WCF service3
    	}
    	catch(Exception ex3)
    	{
    		throw new Exception3
    	}
    
    }
    catch (Exception mainEx)
    {
    //Construct notification msg based on received exception message
    //Send notification about the failure
    }
    

    BizTalk – WCF Exception Handling Scenarios



    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by vdha Friday, January 2, 2015 3:01 PM
    Wednesday, December 31, 2014 6:36 PM
  • Hi ,

    Are you using ESB toolkit to capture your exception ?

    It will be easy to capture your request response process failure as it is capturing System.Exception . Once you have successfully populated the Exception message within ESB Exception DB you can use Exception Management Portal Alerting Service (Notification service )to send error  message along with actual message . It is a windows service which pools exception DB for any new exception  which has occurred in BizTalk Processing .

    Many peoples don't use this approach, but i would tell it is one of the best approach to deal with Exception notification message  .I this case you can send Exception message along with the message which has caused you the exception    .

    There is certain bug with the code which can be rectified easily by following below blog

    Upgrading ESB 2.1 to ESB 2.2 – Exception Management Portal Alerting Service

    The detailed MSDN description can be found in below links

    Install the ESB Management Portal Alert Service

    Configuring Alert Queue Options and Notifications

    Thanks

    Abhishek

    • Marked as answer by vdha Friday, January 2, 2015 3:01 PM
    Wednesday, December 31, 2014 6:22 PM

All replies

  • Hi ,

    Are you using ESB toolkit to capture your exception ?

    It will be easy to capture your request response process failure as it is capturing System.Exception . Once you have successfully populated the Exception message within ESB Exception DB you can use Exception Management Portal Alerting Service (Notification service )to send error  message along with actual message . It is a windows service which pools exception DB for any new exception  which has occurred in BizTalk Processing .

    Many peoples don't use this approach, but i would tell it is one of the best approach to deal with Exception notification message  .I this case you can send Exception message along with the message which has caused you the exception    .

    There is certain bug with the code which can be rectified easily by following below blog

    Upgrading ESB 2.1 to ESB 2.2 – Exception Management Portal Alerting Service

    The detailed MSDN description can be found in below links

    Install the ESB Management Portal Alert Service

    Configuring Alert Queue Options and Notifications

    Thanks

    Abhishek

    • Marked as answer by vdha Friday, January 2, 2015 3:01 PM
    Wednesday, December 31, 2014 6:22 PM
  • Hi Vdha,

    Yes, Delivery notifications do not work with solicit-response transmission.

    When dealing with a WCF service, in general there are 3 types of exception you have to deal with:

    1. Exception when the WCF service is down.
    2. Standard SOAP fault (System.ServiceModel.FaultException)
    3. Type Fault exception, if the WCF implements a custom Fault.

    For exception when the WCF service is down, you can catching with exception with catch block (under a scope) with exception object type System.Exception.

    For standard SOAP fault you can handle by adding fault operation message added to the solicit-response port. (Right click the port and add a fault message).

    For typed fault exceptions from WCF service, for the fault is typed is exposed as a schema which is imported by BizTalk when you generated the metadata using Add generated items wizard.

    Check with your WCF service, if they send typed fault you need to handle the with fault message, otherwise you need to have standard SOAP fault by adding a standard fault message in port.

    When you have more service call and they don’t have typed fault, then you can except standard SOAP fault thrown when there is an issue (or System.Exception in case of transmission), it’s better to handle the standard fault message with System.Exception catch handler. Read the following article which handles these exceptions are handled. When you have a common generic exception handling process like sending the notification, then use "throw new System.Exception" in each of its scope and handle this thrown exception in a catch block which is common to the whole orchestration and construct the notification message and send the notification message in this common catch block. If I translate this into a try-catch block of c# code, this would look like this.. (This C# is just to give you an idea of how this can be constricted in orchestration using scope and catch blocks

    try
    {
    	try
    	{
    		call your WCF service1
    	}
    	catch(Exception ex1)
    	{
    		throw new Exception1
    	}
    	
    	try
    	{
    		call your WCF service2
    	}
    	catch(Exception ex2)
    	{
    		throw new Exception2
    	}
    	
    	try
    	{
    		call your WCF service3
    	}
    	catch(Exception ex3)
    	{
    		throw new Exception3
    	}
    
    }
    catch (Exception mainEx)
    {
    //Construct notification msg based on received exception message
    //Send notification about the failure
    }
    

    BizTalk – WCF Exception Handling Scenarios



    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by vdha Friday, January 2, 2015 3:01 PM
    Wednesday, December 31, 2014 6:36 PM
  • Thanks Ashwin,

    It is a great article. But I couldnot open the sample code given in the link, in visual studio 2010.

    Friday, January 2, 2015 2:48 PM
  • Abhishek,

    Thanks a lot, but I am not using ESB toolkit. I never used it, looking to handle in orchestration.

    Friday, January 2, 2015 2:51 PM
  • Its very easy :) ESB toolkit is a framework to deal with Exception Message . I would suggest you can Utilize it as you are using BizTalk as a product which has different subset for different functionality . It will add value to your Software Architecture 

    Thanks

    Abhishek

    Friday, January 2, 2015 3:09 PM
  • Hi Vdha,

    I don't have access Visual Studio 2010 instance at the moment, may be today evening. But now I have migrated the code to Visual Studio 2008, which you can open in your Visual Studio 2010.

    Try to access this code now..

    https://onedrive.live.com/redir?resid=AC2383A73FFE27CE%21105


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Friday, January 2, 2015 3:37 PM
  • Thanks Ashwin,

    Biut I still cant open, it shows incompatible

    Friday, January 2, 2015 4:03 PM