AddFault method: SOAPDoc class

Syntax

AddFault(Fault_Code, Fault_String, Fault_Format)

Description

Use the AddFault method to add a fault code, its corresponding fault string, and the fault format (optional), to a SOAPDoc. Use this method only in a Response SOAP XML Document. The Envelope and Body sections of the XML Document are automatically added if they don't exist.

Parameters

Parameter Description

Fault_Code

Specify the fault code to add, as a string.

Fault_String

Specify the fault string to add, as a string.

Fault_Format

Specify whether the SOAP schema 1.2 format should be used, as a Boolean value. It is an optional parameter.

The following fault codes are supported:

Fault Code Fault String Description

100

Version Mismatch

The XML version or SOAP version is not supported by the current implementation.

300

Client error

An error occurred on the client while processing the SOAP document.

400

Server error

An error occurred on the server while processing the SOAP document.

Returns

None.

Example

The following example program:

&SOAPDoc = CreateSOAPDoc(); 
&SOAPDoc.AddFault("400", "Server Error");
/* ===> The following statement executes this instance: */
&FaultCode = &SOAPDoc.FaultCode;
&FaultString = &SOAPDoc.FaultString;
&OK = &SOAPDoc.ValidateSOAPDoc();

Creates the following XML:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ⇒
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
- <SOAP-ENV:Body>
- <SOAP-ENV:Fault>
  <faultcode>400</faultcode> 
  <faultstring>SOAP Server Error</faultstring> 
  </SOAP-ENV:Fault> 
  </SOAP-ENV:Body> 
  </SOAP-ENV:Envelope>

In the following example, SOAP schema 1.2 format is used.

The following PeopleCode program:

Local Soapdoc &SOAPDoc1;

&SOAPDoc1 = CreateSOAPDoc();
&SOAPDoc1.AddFault("400", "Server Error", True);

Creates the following XML.

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope/">
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
      <SOAP-ENV:Code>400</SOAP-ENV:Code>
      <SOAP-ENV:Reason>Server Error</SOAP-ENV:Reason>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>