Skip to main content

Fault

Optional

SOAP 1.1: faultcode, faultstring, faultactor, detail

SOAP 1.2: Code (Value+Subcode), Reason, Node, Role, Detail

The Fault element appears inside the Body when an error occurs. SOAP Faults carry a fault code (classification), a human-readable string, and optional detail elements. SOAP 1.1 and 1.2 have different Fault structures. HTTP responses carrying a SOAP Fault use status 500, regardless of whether the fault is a client or server error.

Details

The Fault element is the SOAP error mechanism. It replaces HTTP status codes for application-level errors – SOAP services typically return HTTP 200 for normal responses and HTTP 500 for all SOAP Faults.

SOAP 1.1 Fault structure: faultcode: a qualified name from a fixed set: soap:VersionMismatch, soap:MustUnderstand, soap:Client, soap:Server. Custom subcodes use dot notation: soap:Client.ValidationError. faultstring: human-readable error description (localized text). faultactor: optional URI of the node that generated the fault (for intermediary chains). detail: optional XML element with application-specific error detail. MUST be present if the fault was caused by the Body (not the Header).

SOAP 1.2 Fault structure (more structured): Code/Value: soap:VersionMismatch, soap:MustUnderstand, soap:DataEncodingUnknown, soap:Sender (replaces Client), soap:Receiver (replaces Server). Code/Subcode: recursive subcode element for application-specific error codes. Reason/Text: list of language-tagged reason strings (replaces faultstring). Node: URI of the node that generated the fault. Role: role the node was playing when the fault occurred. Detail: optional XML detail block.

HTTP status code: SOAP Faults are returned with HTTP 500. Some implementations use HTTP 400 for soap:Sender faults (client errors), but this is non-standard.

Examples

SOAP 1.1 client fault (invalid input)
<soap:Body>
  <soap:Fault>
    <faultcode>soap:Client</faultcode>
    <faultstring>Validation failed: CustomerId is required</faultstring>
    <detail>
      <ex:ValidationError xmlns:ex="http://example.com/errors">
        <ex:Field>CustomerId</ex:Field>
        <ex:Message>CustomerId cannot be null or empty</ex:Message>
      </ex:ValidationError>
    </detail>
  </soap:Fault>
</soap:Body>
SOAP 1.2 sender fault (structured)
<soap:Body>
  <soap:Fault>
    <soap:Code>
      <soap:Value>soap:Sender</soap:Value>
      <soap:Subcode>
        <soap:Value>ex:InvalidCustomerId</soap:Value>
      </soap:Subcode>
    </soap:Code>
    <soap:Reason>
      <soap:Text xml:lang="en">Customer cust-999 not found</soap:Text>
    </soap:Reason>
    <soap:Detail>
      <ex:ErrorDetail xmlns:ex="http://example.com/errors">
        <ex:Code>CUSTOMER_NOT_FOUND</ex:Code>
      </ex:ErrorDetail>
    </soap:Detail>
  </soap:Fault>
</soap:Body>

See Also