1. What is SOAP Fault?
-
A SOAP Fault is a special element inside the SOAP Body that is used to report errors.
-
If something goes wrong (client mistake, server issue, invalid message, etc.), the server does not return normal data; instead, it sends back a Fault message.
-
This provides a standard way of error handling in SOAP.
2. Location
3. Structure of SOAP Fault
A SOAP Fault message has these elements:
<soap:Fault>
<faultcode>...</faultcode>
<faultstring>...</faultstring>
<faultactor>...</faultactor>
<detail>...</detail>
</soap:Fault>
Elements:
-
faultcode (mandatory)
-
faultstring (mandatory)
-
faultactor (optional)
-
Indicates which node (server/intermediary) caused the error.
-
Useful in multi-hop SOAP messages (e.g., proxy servers).
-
detail (optional)
4. Example of SOAP Fault
Case: Invalid City in Weather Request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Invalid city name provided</faultstring>
<faultactor>http://www.example.com/weatherService</faultactor>
<detail>
<errorcode>1001</errorcode>
<errormessage>City 'Lnodon' not found in database</errormessage>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
-
faultcode → Client (error caused by bad input).
-
faultstring → "Invalid city name provided".
-
faultactor → Service URL that raised the error.
-
detail → More information for debugging.
5. Key Points about SOAP Fault
-
Fault is used for error handling in SOAP.
-
Always appears inside the SOAP Body.
-
Contains faultcode, faultstring, faultactor, detail.
-
Provides both human-readable and technical details about the error.
-
Ensures that SOAP clients can handle errors in a consistent, standard way.