2

I am trying to return the ErrorReason from the below soap xml response. However it keeps returning empty. I am not sure how to handle the namespace.

I expect to return "The specified envelope has duplicate recipients."

declare @xml xml =
(
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <soap:Header>
    <wsa:Action>http://schemas.xmlsoap.org/ws/2004/08/addressing/fault</wsa:Action>
    <wsa:MessageID>urn:uuid:b0c43031-35b9-40a1-a217-36491cfdd07c</wsa:MessageID>
    <wsa:RelatesTo>urn:uuid:4871a441-ea1e-4f9b-953b-d3f426674597</wsa:RelatesTo>
    <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
    <wsse:Security>
      <wsu:Timestamp wsu:Id="Timestamp-c41a3e0c-317d-46e2-b203-6a0a43450313">
        <wsu:Created>2017-08-31T18:11:00Z</wsu:Created>
        <wsu:Expires>2017-08-31T18:16:00Z</wsu:Expires>
      </wsu:Timestamp>
    </wsse:Security>
  </soap:Header>
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>The specified envelope has duplicate recipients. </faultstring>
      <faultactor>https://www.test.asmx</faultactor>
      <detail>
        <ErrorCode xmlns="missing in Web.Config">140</ErrorCode>
        <ErrorReason xmlns="missing in Web.Config">The specified envelope has duplicate recipients.</ErrorReason>
      </detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>'
)



select  x.value('ErrorReason[1]','VARCHAR(max)') from @xml.nodes('/*:Envelope/*:Body/detail') as X(x)

1 Answer 1

1

you want the below query

select @xml.query('/*:Envelope/*:Body/*:Fault/*:detail/*:ErrorReason/text()')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.