IBM Support

Access SOAP Fault from RPG stubs

News


Abstract

Access SOAP Fault from RPG stubs

Content

 

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:

<faultcode>

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.
<faultstring>
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.
<faultactor>
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.
<detail>
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               *

 

      /free

         .

         .

         .

 

         if stub_create_MathOps(this) = *ON;

           input1.value = 10;

           input2.value = 0;

 

           stub_op_div_op(this:input1:input2:result);

 

           if this.excOccurred = *OFF;

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

           else;

               soapFault = axiscStubGetSOAPFault(this.handle);

               if (soapFault <> *NULL);

                  printf4('FaultCode = %s' + LF:

                       axiscSoapFaultGetFaultcode(soapFault));

                  printf4('FaultString = %s' + LF:

                       axiscSoapFaultGetFaultstring(soapFault));

                  printf4('FaultActor = %s' + LF:

                       axiscSoapFaultGetFaultactor(soapFault));

                  printf4('FaultDetail = %s' + LF:

                       axiscSoapFaultGetSimpleFaultDetail(soapFault));

                endif;

           endif;

           

           stub_destroy_MathOps(this);

         endif;

 

         *inlr=*ON;

      /end-free

 

Why use it?

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

Availability

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

UID

ibm11138648