Accessing SOAP Detail Fault information

The generated FoxPro Web Service Proxy returns a cErrorMsg property which is the main faultstring that the SOAP service provides. This is typically a single line error message that is a high level error message.

However, most SOAP services also support publishing additional Detail error information. How that error information is published depends on the server and may contain single strings or more complex objects. Because the result is not a fixed object or value that can vary in format, this error information is not published by default in the .NET Web Service, but rather is contained as a special Detail property on the SoapException object which is an XmlNode element.

The FoxPro generated proxy includes a cErrorDetailXml property, that captures the raw XML from the SOAPException and makes it available to your code.

*** Make the call to the service
loResponse = loProxy.GetConfiguration(loRequest)

IF VARTYPE(loResponse) # "O"
   *** If there's an error this will be non-blank
   *** Show error message if any 
   ? loProxy.cErrorMsg

   *** Xml Detail message as an XML string
   ? loProxy.cErrorDetailXml
   
   *** Example - parse message out (note this is implementation specific)
   lcError = STREXTRACT(loProxy.cErrorDetailXml,"<a:Message>","</a:Message>")
   ? lcError
   RETURN
ENDIF

The XML data returned will vary but generally start with a <detail> node:

<detail>
  <ValidationFault xmlns="http://www.microsoft.com/practices/EnterpriseLibrary/2007/01/wcf/validation" 
                   xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Details xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF">
      <a:ValidationDetail>
        <a:Key>SystemId</a:Key>
        <a:Message>The value cannot be null.</a:Message>
        <a:Tag>request</a:Tag>
      </a:ValidationDetail>
    </Details>
  </ValidationFault>
</detail>

Always remember that fault detail message formats can change between requests and services. There's probably no easy fixed way to parse this data, but to explicitly retrieve what you are interested in using an XMLDOM parser, or as I've done above simply by extracting a string value:

lcError = STREXTRACT(loProxy.cErrorDetailXml,"<a:Message>","</a:Message>")

What you do with the XML Detail Error Message is entirely up to you.


© West Wind Technologies, 2004-2020 • Updated: 09/29/15
Comment or report problem with topic