locked
WS Error message -- BizTalk RRS feed

  • Question

  • Hi All,

    I have to capture error message in biztalk  from WS and response is in string parameter.

    I have excluded SOAP header and body 

    <OpResult>

    <Response>

    <OperationName>

    <ErrorMessage>Invalid Order Number</ErrorMessage>

    </OperationName>

    </Response>

    </OpResult>

    any suggestions.

     

    Sunday, April 24, 2016 1:33 AM

Answers

  • Hello,

    The response message you have posted is not valid XML. You need to validate the response first.Your elements have no namespace prefix, so it is expecting a default namespace.

    Note: If you are testing this locally, I would recommend to work with generated instance of the response schema. Refer:  How to Generate Instance Messages

    For the Xpath, you can copy the Xpath of ErrorMessage node from the response schema in your project.

    Refer: How to Copy XPath


    Rachit Sikroria (Microsoft Azure MVP)


    Sunday, April 24, 2016 1:34 PM
    Moderator

All replies

  • So the ErrorMessage tag is part of web service response schema itself and in case of failure response the webservice will return the fault message in the ErrorMessage node?

    If you use the XPATH function within the orchestration you would be able to do that. Say your message is RecvMsg and the you need to check for ErrorMessage then in an expression shape within the orchestration you can do the following:

    //
    // XPATH to TranId = //*[local-name()='ErrorMessage']
    if (xpath(RecvMsg, "//*[local-name()='ErrorMessage']") != null)
    {
    // now store it
       stringVar = xpath(RecvMsg, "string(//*[local-name()='ErrorMessage'])");
    }

    You can do the further mapping based on your requirement. 


    Rachit Sikroria (Microsoft Azure MVP)

    Sunday, April 24, 2016 4:22 AM
    Moderator
  • It all depends on if the webservice is generating a SOAP Fault Message for the error, and wrapping the error within the SOAP Fault element, or if they are returning the error within their normal(non-error scenario) response schema. SOAP Fault example - http://www.tutorialspoint.com/soap/soap_fault.htm

    If it is the former, you need to handle the SOAP Fault Message differently within BizTalk. Some references on how to achieve this-

    1)Messaging Only scenario-

    https://social.msdn.microsoft.com/Forums/en-US/bf4f5e54-09a6-4244-9b1a-fcc86ad888b4/how-to-handle-soap-fault-exceptions-in-message-only-scenario?forum=biztalkgeneral

    2)If orchestration is calling the WS-

    https://blogs.msdn.microsoft.com/biztalknotes/2013/02/12/how-to-handle-fault-message-in-biztalk-server/

    If it is the latter, it has already been covered here.


    Thanks Arindam



    Sunday, April 24, 2016 5:26 AM
    Moderator
  • Thanks Rachit,

    Apologies , I missed schema version previously.

    <OpResult>

    <Response SchemaVersion=8.2 xmlns="">

    <OperationName>

    <ErrorMessage>Invalid Order Number</ErrorMessage>

    </OperationName>

    </Response>

    </OpResult>

    When I am using below code

    if (xpath(RecvMsg, "//*[local-name()='ErrorMessage']") != null) { // now store it stringVar = xpath(RecvMsg, "string(//*[local-name()='ErrorMessage'])"); }

    following is the Error

    ShapeId: 00000000-0000-0000-0000-000000000000

    Inner exception : There is an error in the XML document.

    <Reason xmlns="> was not expected.

    Any suggestions, where I going wrong.

     


    Sunday, April 24, 2016 1:16 PM
  • Hello,

    The response message you have posted is not valid XML. You need to validate the response first.Your elements have no namespace prefix, so it is expecting a default namespace.

    Note: If you are testing this locally, I would recommend to work with generated instance of the response schema. Refer:  How to Generate Instance Messages

    For the Xpath, you can copy the Xpath of ErrorMessage node from the response schema in your project.

    Refer: How to Copy XPath


    Rachit Sikroria (Microsoft Azure MVP)


    Sunday, April 24, 2016 1:34 PM
    Moderator