Using HTTP adapter to consume a RESTFul service - How to retrieve the response message when failure RRS feed

  • Question

  • We are using BTS 2010. The requirement is to consume a RESTFul service. It's just a HTTP POST, so I did not have to use a custom solution such as "REST Start Kit". Instead, I'm using the HTTP adapter. Everything works fine in the successful scenarios. However, the challenge is when it fails with the non-successful HTTP code (e.g. 400, 500). The client is including the detail error message in the response body, so it's critical for us to handle it properly. What I'm trying to do in case of the failure:

    1. Get the HTTP status code (e.g. 400, 500)

    2. Get the response message

    Will this be possible to do with the HTTP adapter?

    Thanks in advance!

    Thursday, April 7, 2016 5:47 PM


All replies

  • Hi,

    Thank you for posting on MSDN forum.

    Yes, it is doable with HTTP adapter. I assume for successful scenarios you have created some ResponseSchema that captured the response code and text.

    If not, I would propose below solution.

    1. Create separate schema for response like below screen-shot,

    2. And Map it with received response back from client.

    In that way, you can capture all code as well as the received response messages.



    If my reply is helpful please mark as Answer or vote as Helpful.

    My blog | Twitter | LinkedIn

    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

    Thursday, April 7, 2016 6:07 PM
  • Hi Windong,

    I have done exactly that using WCF-WebHTTP adapter. It is very easy and convenient. Any particular reason you wouldn't want to use that adapter? Let me know and I'll provide you with some more details.

    Either way, if you are sending from an orchestration you should be able to obtain the response message in the Catch Exception shape and consume it from there. Something close to this:

    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.

    Mauricio Feijo

    Thursday, April 7, 2016 6:09 PM
  • Hi Kamlesh,

    The issue is that when the REST service returns 400 or 500 HTTP code, the adapter fails, and the orchestration receives an exception. From here, I don't know how to get the HTTP code and the response message.

    Since this is a REST service, I can't even catch the NACK message as we do for SOAP. There is no SoapException in my case.


    Thursday, April 7, 2016 6:50 PM
  • Hi Mauricio,

    I'm using BTS 2010, and there is no WCF-WebHTTP adapter.


    Thursday, April 7, 2016 6:52 PM
  • Hi Mauricio,

    I'm using BTS 2010, and there is no WCF-WebHTTP adapter.


    For catching protocol exception consider the below links. You have to create a custom binding element which in turn will create the corresponding WCF channel to handle the interaction with the service, so once the ProtocolException comes you can handle it.


    You have to use WCF-Custom adapter with Behavior Extension for BizTalk Server 2010. 

    Check this url  will help you how to implement ..MessageInspector class


    FYI, If you use HTTP adapter to send message (post/GET) to RestFul service, HTTP-adapter doesn’t allow you to access the status code of the response message directly. So when you have error returned in RestFul service, it would return a different HTTP status code as 400, 500 (not 200) etc. So to handle the exception in BizTalk, you need to access the returned status code from Resful which is bit tough (I have not able to crack it yet) for handling exceptions.

    Rachit Sikroria (Microsoft Azure MVP)

    • Proposed as answer by Angie Xu Monday, April 18, 2016 1:27 AM
    • Marked as answer by Angie Xu Monday, April 18, 2016 1:28 AM
    Thursday, April 7, 2016 7:09 PM
  • Hi windong,

    Please check my technet article on the same issue.

    BizTalk Server 2013 R2: Handle exceptions from REST services in Orchestration


    Friday, April 8, 2016 1:36 AM