!--a11y-->
Customizing the SOAP Fault Element Inside the
Web Service 
The IsoapFaultException interface provides methods for customizing the content of the SOAP Fault subelements – faultstring, faultcode, and faultactor inside your application to implement the com.sap.engine.interfaces.webservices.runtime.soaphttp.IsoapFaultException interface.
This interface has to be implemented by a user-defined exception to provide the Web service runtime with data, which is to be set in the SOAP Fault subelements.
The IsoapFaultException interface contains the following methods:
· public String _getFaultCode() – Returns the value that will be set in the <faultcode> element. If the value is QName, the prefix will be mapped to the namespace returned by the getFaultCodeNS(), otherwise a default prefix will be used. If this method returns null, then the default faultcode will be used.
· public String _getFaultCodeNS() – Returns the namespace string denoting the namespace to which the fault code returned by getFaultCode() method belongs.
· public String _getFaultString() – Returns the string value that will be used as the value of the <faultstring> element. If the value is null, then getLocalizedMessage() of java.lang.Throwable returned value is used.
· public String _getFaultStringLang() – Returns the string value that will be used as the value of the xml:lang attribute on the <faultstring> element. If the value is null, the xml:lang attribute will not tbe set.
· public String _getFaultActor() – Returns the string value that will be used as value of the <soapactor> element. If null is returned, this element will not be present.
import com.sap.engine.interfaces.webservices.runtime.soaphttp.ISoapFaultException;
public class MySoapException extends Exception implements ISoapFaultException { public String strValue; public int intValue; String faultCode = "MyCode"; String faultCodeNS = "urn:myns/faultcodes"; String faultString = "FaultString userdefined value"; String faultStringLang = "someLanguage"; String faultActor = "FaultActor userdefined value";
public String _getFaultCode() { // TODO Auto-generated method stub return faultCode; } public String _getFaultCodeNS() { // TODO Auto-generated method stub return faultCodeNS; } public String _getFaultString() { // TODO Auto-generated method stub return faultString; } public String _getFaultStringLang() { // TODO Auto-generated method stub return faultStringLang; } public String _getFaultActor() { // TODO Auto-generated method stub return faultActor; } } |
So when at runtime a business method invocation throws MySoapException, the runtime will use the strings returned by the IsoapFaultException methods to set SOAP Fault faultstring, faultcode, and faultactor elements. The other subelement of the SOAP Fault, detail, will be completed with data as it is described by the schema in the WSDL file.
