none
How to retrieve REST service response status code RRS feed

  • Question

  • Hello,

    How can I retrieve REST service response status code into BizTalk ? WCF-WebHttp adapter do not have default mechanism to return status code. In case of errors, we receive status into error message as below

    System.Net.WebException: The remote server returned an unexpected response: (400) Bad Request. {Message}.

    For success status 200 , even this is not.

    Thanks in advance.

    Regards,

    Monika 

    Monday, October 17, 2016 10:30 AM

Answers

  • Actually you can't check the WCF.InboundHttpStatusCode ContextProperty and its value either as they aren't set on any error except for a 200 series codes.  Also listed in the blog post you linked to.

    https://cdijkgraaf.wordpress.com/2016/08/12/biztalk-2013-r2-known-bugs-issues-quirks/

    BUG: BIZTALK WCF-WEBHTTP ADAPTER DOES NOT DETECT 500 ERROR & HTTP  STATUSCODE NOT AVAILABLE FOR OTHER ERRORS CODES

    (Note: it used to also not throw an exception for a 500 series error, but that has since been resolved)


    Wednesday, October 19, 2016 12:17 AM

All replies

  • Hello Monika,

    Refer: http://stackoverflow.com/questions/31613171/biztalk-catch-http-response-code

    Yes there is an issue with the WCF-WebHttp adapter in that it does not set the Message Type context property if there is a fault and so it then does not go the the Fault type defined on the port.
    The only way to catch it is in a System.Exception block. You can check for the WCF.InboundHttpStatusCode ContextProperty and its value.

    See blog post BizTalk 2013 R2 known bugs, issues & quirks, BUG: BIZTALK WCF-WEBHTTP ADAPTER DOES NOT SET MESSAGE TYPE ON ERROR

    Also please note that if the end systems throws a 500 status code, it is NOT thrown as an error at all and you have to check the status code yourself.

    See BizTalk WCF-WebHttp adapter does not detect 500 error


    Rachit Sikroria (Microsoft Azure MVP)


    Monday, October 17, 2016 10:45 AM
    Moderator
  • Hi Monika,

    yes this is one of the known issues of the WCF-Webhttp adapter .

    The issue is that it does not set the MessageType Property in the message context and hence does not go through the fault type defined on the port.

    Refer Similar threads for details

    json-catch biztalk rest response codes

    You can look into catching the service execution exception(be it any error code) using the exception block. You can look into the BizTalk Server: REST Services Error Handling for catching the errors.


    Mandar Dharmadhikari

    Monday, October 17, 2016 11:12 AM
  • Actually you can't check the WCF.InboundHttpStatusCode ContextProperty and its value either as they aren't set on any error except for a 200 series codes.  Also listed in the blog post you linked to.

    https://cdijkgraaf.wordpress.com/2016/08/12/biztalk-2013-r2-known-bugs-issues-quirks/

    BUG: BIZTALK WCF-WEBHTTP ADAPTER DOES NOT DETECT 500 ERROR & HTTP  STATUSCODE NOT AVAILABLE FOR OTHER ERRORS CODES

    (Note: it used to also not throw an exception for a 500 series error, but that has since been resolved)


    Wednesday, October 19, 2016 12:17 AM