pp108 : xforms-onsoapfault

xforms-onsoapfault

This event is fired when the SOAP Fault is received from the Application Service.

Event Information

To invoke

Send an invalid request to the Application Service.

Default Action

Initiates any action associated with this event.

Named Script

xforms-onsoapfault

Event Object Properties

Property

Description

httpStatusCode

String that denotes the HTTP status of a SOAP fault, when it occurs.

faultActor

String that holds the fault actor specified in the SOAP Fault.

faultCode

String that contains the type of fault that occurred. It can be a Read or a Write error.

faultDetail

Refers to the <detail> node of the SOAP Fault.

faultNode

Object that denotes the SOAP:Fault node returned by the Application Service. This property is available with the event object of each SOAP Fault. This XML contains the complete SOAP Fault. To cancel the display of the message, set the value of this property to false.

faultString

String that contains the exact error that occurred. This property is available with the event object of each SOAP Fault.

response

Object that denotes the response object returned by the Application Service.

showError

Boolean that denotes whether the SOAP:Fault can be shown to the user or not.

  • true: Default. SOAP Fault is shown to the user.
  • false: SOAP Fault is not shown to the user.

An event handler can access the event object and its properties through the eventObject available as a parameter on the handler.

Example1

This sample code demonstrates how the method can be used.

Create a webservice that will return the employee details on entering the Employee ID. If we enter an invalid Employee ID we will get a SOAP Fault from the database indicating database read failed. In order to handle the SOAP Faultand show the custom message we can use xforms-onsoapfault event present in the model properties events. For handling SOAP Fault, open the property sheet of the model, click Events tab and select SOAP Fault event.

The following is the code for handling the SOAP Fault that also displays a custom user friendly message.

function EmployeesModel_xformsonsoapfault(eventObject)
{
   //Do not show the database error if SOAP Fault occurs
   eventObject.showError = false;

   //Custom user friendly message indicating the error
    application.inform("Employee ID is invalid");

}

Example2

function EmployeesModel_xformsonsoapfault(eventObject)
{
   //Do not show the SOAP Fault if the fault node has the messageCode "Cordys.LDAP.Messages.updateLdapError"
   var faultNode = eventObject.faultNode;
   if (cordys.gettextContent(cordys.selectXMLNode(faultNode,".//*[local-name()='SOAP:MessageCode']")).indexOf("Cordys.LDAP.Messages.updateLdapError") > 0)
 eventObject.showError = false;
}

Applies to

Model