XML

The Fault Element

A Fault element can contain four child elements: faultcode, faultstring, faultactor, and detail. The fault codes are identified at the URL http://schemas.xmlsoap.org/soap/envelope. The currently available code values are shown in the following table.

Currently Available Fault Code Values

Name Meaning
VersionMismatch

The call used an invalid namespace.

MustUnderstand

The receiver did not understand an XML element that was received containing an element tagged with mustUnderstand="true".

Client

These are a class of errors that were caused by improper information in the actual SOAP message. For example, a new order could be missing a required value such as the item number or amount. These errors represent a problem with the actual message content and indicate that the message should not be resent without change. A class of client errors can be created using the dot (.) operator. For example, you could have Client.InvalidPartNumber, Client.InvalidQuantity,and so on.

Server

These errors are related to problems with the server and usually do not represent problems with the actual SOAP message. These messages might be resent at a later time to the server. A class of server errors can be created using the dot (.) operator.

The faultstring element is a string. It is not used by applications; it is used only as a message to users. This element is required. The faultactor element can provide information about which element in the message path caused the fault to occur. The faultactor will be a URI that identifies the source. If the fault occurs in an application that is not the ultimate destination of the message, the faultactor element must be included. If the fault occurs in the ultimate destination, the faultactor is not required but may be included. The detail element is required if the contents of the SOAP Body element couldn't be processed. It provides application-specific error information related to the Body element. You cannot include error information related to the header in the detail element. Any child elements of the detail element must be associated with a namespace.

A return package with a Fault element will look like this:

  HTTP/1.1 200 OK
  Content-Type: text/xml
  Content-Length: nnnn
  <SOAP-ENV:Envelope
     xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance"
     xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope"
     xsi:schemaLocation=
        "http://www.northwindtraders.com/schemas/NPOSchema.xsd">
        <SOAP-ENV:Fault>
           <SOAP-ENV:faultcode>200</SOAP-ENV:faultcode>
           <SOAP-ENV:faultstring>Must Understand Error
           </SOAP-ENV:faultstring>
           <SOAP-ENV:detail xsi:type="Fault">
              <errorMessage>
                 Object not installed on server.
              </errorMessage>
           </SOAP-ENV:detail>
        </SOAP-ENV:Fault >
     </SOAP-ENV:Body>
  </SOAP-ENV:Envelope>

Using the faultstring element, you can pass information back to the client that describes the exact error. The faultstring element can handle a wide range of errors.