none
Handling 400 exception- Biztalk 2013 R2-RESTFul JSON RRS feed

  • Question

  • Hi,

    I am trying to handle 400 exception in orchestration. I kept system Exception in it. I am able to get the response as required but with extra information in it. I just need Invalid format message but not the rest of the message.

    {
      "message": "An error occurred while processing the message, refer to the details section for more information \r\nMessage ID: {A9BE7E78-FEB2-4F16-B6C5-515145D6A2DF}\r\nInstance ID: {F5C4991D-C7EF-4821-981C-B9DFBAFC428E}\r\nError Description: System.Net.WebException: The remote server returned an unexpected response: (400) Bad Request.\r\n{\"message\":\"Invalid  format\"}\r\n"
    }

    Any inputs are highly appreciated.

    Thanks,

    ChanderDP

    Thursday, January 19, 2017 6:00 AM

Answers

All replies

  • Thursday, January 19, 2017 8:28 AM
    Moderator
  • Hi Rachit,

    Thanks for your input. I have implemented the same code as in https://blog.tallan.com/2014/09/29/wcf-webhttp-and-custom-json-error-messages/  but no luck.

    Do I need to write the above code in 'BeforeSendRequest' of IClientMessageInspector?

    Thanks,

    Chander DP


    • Edited by ChanderDP Thursday, January 19, 2017 9:56 AM Typo
    Thursday, January 19, 2017 9:56 AM
  • Hi ChanderDP

    This is an IErrorHandler Implementation.

    You don't need IClientMessageInspector, you have to add the ErrorHandler as an EndPoint behavior (using ApplyDispatchBehavior method) as shown in the post -

    SanitizedJsonFaultBehavior


    Thanks Arindam


    Thursday, January 19, 2017 10:25 AM
    Moderator
  • Hi Arindham,

    Thanks for your input.

    After implementing IErrorHandler I got below response. How can I get only highlighted JSON message?

     {
      "message": "<SOAP:Envelope xmlns:SOAP=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><SOAP:Body><SOAP:Fault><faultcode>Microsoft BizTalk Server Negative Acknowledgment </faultcode><faultstring>An error occurred while processing the message, refer to the details section for more information </faultstring><faultactor>https://xyz.com</faultactor><detail><ns0:NACK Type=\"NACK\" xmlns:ns0=\"http://schema.microsoft.com/BizTalk/2003/NACKMessage.xsd\"><NAckID>{4A548594-D6C4-4D90-AB30-D617A6346263}</NAckID><ErrorCode>0xc0c0167a</ErrorCode><ErrorCategory>0</ErrorCategory><ErrorDescription>System.Net.WebException: The remote server returned an unexpected response: (400) Bad Request.\r\n {\"message\":\"Invalid time format\"} </ErrorDescription></ns0:NACK></detail></SOAP:Fault></SOAP:Body></SOAP:Envelope>\r\n"
    }

    Thanks,

    Chander DP


    • Edited by ChanderDP Friday, January 27, 2017 5:39 AM Typo
    Wednesday, January 25, 2017 5:53 AM
  • Hello ,

    You are getting exception as JSON payload .

    How about converting it into xml using JSON decode pipeline component at the send port receive side and then capture the SOAP exception within the Orchestration . You can also work with direct bound ports to accept xmldocument type message within Orchestration and then iterate over Xpath to get the exception message.

    Thanks

    Abhishek


    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

    Wednesday, January 25, 2017 6:07 AM