IBM Support

Access SOAP Fault from RPG stubs



Access SOAP Fault from RPG stubs



What is it?

When using RPG stubs to invoke SOAP web services and a SOAP fault is returned by the server, there was no way to retrieve the SOAP fault data.  If an error occurs in a web service, a fault message is returned to the client. The basic structure of the fault message is defined in the SOAP specifications. Each fault message can include XML that describes the specific error condition.

In SOAP 1.1, the SOAP <Fault> element contains the following elements:


The <faultcode> element is a mandatory element in the <Fault> element. It provides information about the fault in a form that can be processed by software. SOAP defines a small set of SOAP fault codes covering basic SOAP faults, and this set can be extended by applications.
The <faultstring> element is a mandatory element in the <Fault> element. It provides information about the fault in a form intended for a human reader.
The <faultactor> element contains the URI of the SOAP node that generated the fault. A SOAP node that is not the ultimate SOAP receiver must include the <faultactor> element when it creates a fault. An ultimate SOAP receiver is not obliged to include this element, but may do so.
The <detail> element carries application-specific error information related to the <Body> element. It must be present if the contents of the <Body> element were not successfully processed. It must not be used to carry information about error information belonging to header entries. Detailed error information belonging to header entries must be carried in header entries.


This enhancement gives you the ability to retrieve the SOAP fault data.  The data is returned as NULL-terminated strings. Here is code snippet in how one would access the SOAP fault:


      /copy /qibm/proddata/os/webservices/v1/client/include/Axis.rpgleinc


     d soapFault       s               *







         if stub_create_MathOps(this) = *ON;

           input1.value = 10;

           input2.value = 0;




           if this.excOccurred = *OFF;

             printf('Result is ' + %char(result.value) + LF);


               soapFault = axiscStubGetSOAPFault(this.handle);

               if (soapFault <> *NULL);

                  printf4('FaultCode = %s' + LF:


                  printf4('FaultString = %s' + LF:


                  printf4('FaultActor = %s' + LF:


                  printf4('FaultDetail = %s' + LF:











Why use it?

Primary use case would be for client applications that want to determine why an error happened or to log an error. 


The support is enabled in the following HTTP Group PTFs:

V7R1M0 SF99368-Level 52

V7R2M0 SF99713-Level 26

V7R3M0 SF99722-Level 13

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
30 December 2019