none
WCF-SQL exception handling In orchestration RRS feed

  • Question

  • HI Experts,

    Currently am calling WCF-sql adapter to insert data and receives the response back to orchestration.
    My point here is , if some error happens how can i catch that exception in orchestraion exception handler.

    I tried many ways but can't succeed, please share any link if possible.
    Tuesday, January 13, 2015 3:37 PM

Answers

  • When you have WCF-SQL adapter with solicit-response (two-way) port, you don’t need to worry much. When you send the request to execute the insert, if it works you will get response otherwise you will not get any response. So when you don’t get the response, handle it in exception handler.

     

    So you need to have

    • Standard transactional scope with exception handle for generic exception of type System.Exception. This will capture any issue in sending the message to the SQL and if there are any issues in this message transmission.
    • Then you need to have LISTEN shape. On one-side of the Listen shape drop the Receive shape which would receive the response from the SQL. And do whatever you want to do during the happy scenario. On the other-side of the Listen shape, have “DELAY” shape and configure a timeout period. And under the Delay shape have a expression with following code. This would throw exception of you don’t receive the response in the configured time. i.e if there are any failures in executing the insert statement in SQL, you will get any response, so after the configured time you will throw as error.
    throw new System.Exception("Response not received from SQL. Error occured");

    So you orchestration can look something like this..


    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 sandydv85 Monday, January 19, 2015 12:51 PM
    Tuesday, January 13, 2015 6:38 PM
  • Hi ,

    You need to capture Exception Object ex (type of System.Exception ) .The exception object will contain all the exception details and you need to construct exception message with the exception object .

    I have already mentioned in my earlier post which you can refer.

    Thanks

    Abhishek

    • Marked as answer by sandydv85 Monday, January 19, 2015 12:51 PM
    Wednesday, January 14, 2015 11:37 AM
  • You can have  a scope shape with an exception block capturing your exception . If You are using ESB Exception Management Portal than constructing the exception message in simple steps .

    You can look into below Code Project article

    How To Handle Exceptions in BizTalk Server 2009 using ESB Toolkit 2.0

    You can also look into earlier post

    catch sql exceptions in orchestration

    If still you have any specific requirement than you can let us now  .

    Sample Orchestration is shown below


    Thanks

    Abhishek

     

    Tuesday, January 13, 2015 6:01 PM
  • Hi,

     If the custom exception is going to comeback as part of your response, then the response shall handle it. If you’re going to send the response with the any error details, then after receiving the response, check the content of the response using XPath and look for the element where your error message is populated. If there is any error, throw an exception as below which would be caught by your general System.Exception.

    throw new System.Exception("Error response received from DB. ErrorDetails"+ varErrorDetailGotThruXPath);

    Also small change in above diagram, don't keep the receive (which receive the response) under the Listen shape. If so, you will get the build error as "incomplete requestresponse operation; missing 'receive'". Just keep the receive shape next to next to the send i.e send the response and receive the response all next to each other. And if any timeout occurs it will be caught by the general System.Exception.

    Note: I don't want to edit my previous post as others did. Instead want to give clarification for the questioner. Intension is to help the questioner, nothing else.

     


    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 Angie Xu Monday, January 19, 2015 2:23 AM
    Thursday, January 15, 2015 11:22 AM

All replies

  • Hi Sandy,

    Set delivery notification to "Transmitted" in send port properties.(Default is None) You can find this property in orchestration designer.

    Thanks,

    Prakash

    Tuesday, January 13, 2015 5:11 PM
  • You can have  a scope shape with an exception block capturing your exception . If You are using ESB Exception Management Portal than constructing the exception message in simple steps .

    You can look into below Code Project article

    How To Handle Exceptions in BizTalk Server 2009 using ESB Toolkit 2.0

    You can also look into earlier post

    catch sql exceptions in orchestration

    If still you have any specific requirement than you can let us now  .

    Sample Orchestration is shown below


    Thanks

    Abhishek

     

    Tuesday, January 13, 2015 6:01 PM
  • I would recommend you to go through this link.

    BizTalk: Handling SQL Adapter Exceptions to resume suspended orchestrations

    In case of WCF-SQL you shoud catch SOAP Exception, as WCF adapters do not support one way operation.

    Rachit


    Please mark as answer or vote as helpful if my reply does




    Tuesday, January 13, 2015 6:05 PM
    Moderator
  • When you have WCF-SQL adapter with solicit-response (two-way) port, you don’t need to worry much. When you send the request to execute the insert, if it works you will get response otherwise you will not get any response. So when you don’t get the response, handle it in exception handler.

     

    So you need to have

    • Standard transactional scope with exception handle for generic exception of type System.Exception. This will capture any issue in sending the message to the SQL and if there are any issues in this message transmission.
    • Then you need to have LISTEN shape. On one-side of the Listen shape drop the Receive shape which would receive the response from the SQL. And do whatever you want to do during the happy scenario. On the other-side of the Listen shape, have “DELAY” shape and configure a timeout period. And under the Delay shape have a expression with following code. This would throw exception of you don’t receive the response in the configured time. i.e if there are any failures in executing the insert statement in SQL, you will get any response, so after the configured time you will throw as error.
    throw new System.Exception("Response not received from SQL. Error occured");

    So you orchestration can look something like this..


    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 sandydv85 Monday, January 19, 2015 12:51 PM
    Tuesday, January 13, 2015 6:38 PM
  • Hello Prabhu,

    Here you are throwing custom exception, but i need to know the exact exception happened like

    For ex:-If i given the invalid insert data or like i have given the invalid DB in send port.

    Because i need to know the exact error..

    thanks in Advance..

    Tuesday, January 13, 2015 11:53 PM
  • Hi,

    when in exception block, you can get those details from the caught exception.


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.

    Wednesday, January 14, 2015 11:28 AM
  • Hi ,

    You need to capture Exception Object ex (type of System.Exception ) .The exception object will contain all the exception details and you need to construct exception message with the exception object .

    I have already mentioned in my earlier post which you can refer.

    Thanks

    Abhishek

    • Marked as answer by sandydv85 Monday, January 19, 2015 12:51 PM
    Wednesday, January 14, 2015 11:37 AM
  • Hi,

     If the custom exception is going to comeback as part of your response, then the response shall handle it. If you’re going to send the response with the any error details, then after receiving the response, check the content of the response using XPath and look for the element where your error message is populated. If there is any error, throw an exception as below which would be caught by your general System.Exception.

    throw new System.Exception("Error response received from DB. ErrorDetails"+ varErrorDetailGotThruXPath);

    Also small change in above diagram, don't keep the receive (which receive the response) under the Listen shape. If so, you will get the build error as "incomplete requestresponse operation; missing 'receive'". Just keep the receive shape next to next to the send i.e send the response and receive the response all next to each other. And if any timeout occurs it will be caught by the general System.Exception.

    Note: I don't want to edit my previous post as others did. Instead want to give clarification for the questioner. Intension is to help the questioner, nothing else.

     


    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 Angie Xu Monday, January 19, 2015 2:23 AM
    Thursday, January 15, 2015 11:22 AM