none
WCF-WebHttp BizTalk 2013 - how to catch HTTP 400 response RRS feed

  • Question

  • Hi,

    I did not find any specific solution to handle Restful exceptions in Biztalk 2013 and using WCF-WebHttp to consume service.

    Can anyone suggest me how to handle exceptions in the orchestration?



    • Edited by Narasaiah Tuesday, July 21, 2015 8:56 AM
    Tuesday, July 21, 2015 8:53 AM

Answers

  • It's important to point out that there is nothing special about "RESTful" exceptions.  You can handle them just like any other Exception type using a Catch Block in a Scope.

    The steps in the above article merely surface the specific protocol error.

    • Marked as answer by Angie Xu Thursday, July 30, 2015 1:09 AM
    Tuesday, July 21, 2015 11:50 AM
  • Yes , I do agree with Boatseller . You can capture your Exception  by having a try -catch block and defining the exception message type .

    Now as your question points to capturing protocol exception(how to catch HTTP 400) you can use the link mentioned above .

    Thanks
    Abhishek

    • Marked as answer by Angie Xu Thursday, July 30, 2015 1:09 AM
    Tuesday, July 21, 2015 12:04 PM

All replies

  • Hi,

    Hope below TechNet Wiki helps for capturing error in rest service .

    http://social.technet.microsoft.com/wiki/contents/articles/16625.biztalk-server-rest-services-error-handling.aspx

    Thanks

    Abhishek

    Tuesday, July 21, 2015 9:20 AM
  • Is it applicable to Biztalk 2013 and dont have any standard way to handle with wcf-webhttp adapter?
    Tuesday, July 21, 2015 9:38 AM
  • Hi,

    Yes, XlangSoapException behavior is same with BizTalk 2010 and BizTalk 2013 . You can apply similar behaviour to capture protocol exception inside your Orchestration .

    Thanks
    Abhishek

    Tuesday, July 21, 2015 10:04 AM
  • Thanks Abhishek for your quick response.

    Is this "WebRequestInterceptor" need to be applied under WCF-webHttp Behavior tab.

    Sorry I am not sure can you please suggest me?

    Tuesday, July 21, 2015 11:05 AM
  • It's important to point out that there is nothing special about "RESTful" exceptions.  You can handle them just like any other Exception type using a Catch Block in a Scope.

    The steps in the above article merely surface the specific protocol error.

    • Marked as answer by Angie Xu Thursday, July 30, 2015 1:09 AM
    Tuesday, July 21, 2015 11:50 AM
  • Yes , I do agree with Boatseller . You can capture your Exception  by having a try -catch block and defining the exception message type .

    Now as your question points to capturing protocol exception(how to catch HTTP 400) you can use the link mentioned above .

    Thanks
    Abhishek

    • Marked as answer by Angie Xu Thursday, July 30, 2015 1:09 AM
    Tuesday, July 21, 2015 12:04 PM
  • Yes, I want to capture protocol exception and exception message. I will try above suggestions and will get back if i have any issues. 

    Tuesday, July 21, 2015 12:50 PM
  • Well, the protocol exception wasn't part of the original question and in practice, is only marginally useful.

    I would get the exception handling working first, then worry about such specifics.

    Tuesday, July 21, 2015 1:59 PM
  • Hi,

    Having the same problem in BizTalk 2016 with WebHttp adapter. Can only catch System.Exception which solves my problem with Error 400 but any other error like 404 will generate an Suspend XLANG Orchestartion.

    Looked at link regarding the protocol exception but I can't find the sample code. Any one have the sample code available for catching the protocolexception so I can catch the error 404 in my Orchestartion?

     


    Ralf

    Sunday, October 4, 2020 5:51 PM
  • Make sure you are catching a System.Exception and not a System.SystemException in your Orchestration, as System.SystemException will not catch XLang exceptions.
    Monday, October 5, 2020 1:27 AM
  • I have an exception block with System.Exception and it catches REST validation errors (400) but not the 404. I get the following back:

    xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Orchestrations.REST(a3639d3e-d82c-12d0-46db-b7a1d101d475)'.
    The service instance will remain suspended until administratively resumed or terminated. 
    If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
    InstanceId: 17e2277f-897f-40e4-9f3b-79327a66eb4a
    Shape name: 
    ShapeId: 00000000-0000-0000-0000-000000000000
    Exception thrown from: segment 4, progress 12
    Inner exception: Object reference not set to an instance of an object.
            
    Exception type: NullReferenceException
    Source: Orchestrations
    Target Site: Microsoft.XLANGs.Core.StopConditions segment4(Microsoft.XLANGs.Core.StopConditions)
    The following is a stack trace that identifies the location where the exception occured

       at Orchestrations.REST.segment4(StopConditions stopOn)
       at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)

     


    Ralf

    Monday, October 5, 2020 6:53 AM
  • Hi,

    problem Solved. :-) The Exception block was triggered but there was an issue with the Exception handlig which created the "Inner exception: Object reference not set to an instance of an object."

    /Ralf


    Ralf

    Monday, October 5, 2020 10:02 AM