Answered by:
WS Error message -- BizTalk

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)
- Edited by Rachit SikroriaModerator Sunday, April 24, 2016 2:03 PM
- Proposed as answer by Angie Xu Tuesday, May 3, 2016 2:53 AM
- Marked as answer by Angie Xu Tuesday, May 3, 2016 2:53 AM
Sunday, April 24, 2016 1:34 PMModerator
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 AMModerator -
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-
2)If orchestration is calling the WS-
If it is the latter, it has already been covered here.
Thanks Arindam
- Edited by Arindam Paul RoyEditor Sunday, April 24, 2016 5:50 AM
Sunday, April 24, 2016 5:26 AMModerator -
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)
- Edited by Rachit SikroriaModerator Sunday, April 24, 2016 2:03 PM
- Proposed as answer by Angie Xu Tuesday, May 3, 2016 2:53 AM
- Marked as answer by Angie Xu Tuesday, May 3, 2016 2:53 AM
Sunday, April 24, 2016 1:34 PMModerator