Handling SOAP Faults
When you complete this lesson you should be able to: Overview When you complete this lesson you should be able to: Describe what a SOAP Fault is Describe the parts of a SOAP message Describe the elements of a SOAP Fault Implement the 4GL code to handle a SOAP Fault
Ignoring a SOAP Fault Web service 4GL application 2 1 3 4 5 operations: . . . GetInvoice: { RETURN ERROR “Invoice not found”. } 4GL application GetInvoice_Request (iInvoiceNum) 2 1 RUN GetInvoice IN hPortType (INPUT iInvoiceNum, OUTPUT cInvoice). GetInvoice_Response ( ) SOAP Fault 3 4 5 NO-ERROR was not used
From Web service (success) From Web service (failure) The SOAP Message SOAP Envelope SOAP Body To Web service operation name input parameters SOAP Envelope SOAP Body From Web service (success) operation name output parameters SOAP Envelope SOAP Body From Web service (failure) SOAP Fault
SOAP Fault element <SOAP-ENV:Envelope . . .> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>An error was detected while executing the Web Service request. (10893)</faultstring> <detail> . . . </detail> <faultactor> http://nberosenbe1:8080/wsa/wsa using urn:OpenEdgeServices:NewCoService </faultactor> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Fault detail element <FaultDetail xmlns:ns1="http://nberosenbe1:8080/wsa/wsa1" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <errorMessage xsi:type="xsd:string"> msg=The server application returned the error: Invoice not found; targetException=ERROR condition: The Server application has returned an error. (7243) (7211)]</errorMessage> <requestID xsi:type="xsd:string"> 172247e5b58beb30:5bb966:fb5df25c30:-7fff#8c </requestID> </FaultDetail> </detail>
Lab 7-1: Generating and viewing a SOAP Fault
Handling a SOAP Fault RUN SendOrders IN hPortType ( INPUT cOrders, OUTPUT iInvoiceNum) NO-ERROR. IF ERROR-STATUS:NUM-MESSAGES > 0 THEN DO: /* now look into what the content is for the SOAP Fault */ END. 1 2
ERROR-STATUS object hierarchy ERROR-OBJECT-DETAIL SOAP-FAULT-DETAIL
The faultstring in a SOAP message <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>An error was detected while executing the Web Service request. (10893)</faultstring> <detail> <ns1:FaultDetail SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://nberosenbe1:8080/wsa/wsa1"> <errorMessage xsi:type="xsd:string">msg=The server application returned the error: Invoice not found; targetException=ERROR condition: The Server application has returned an error. (7243) (7211)]</errorMessage> <requestID xsi:type="xsd:string">172247e5b58beb30:5bb966:fb4fdb744a:-7fff#9</requestID> </ns1:FaultDetail> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
The detail in a SOAP message <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>An error was detected while executing the Web Service request. (10893)</faultstring> <detail> <ns1:FaultDetail SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://nberosenbe1:8080/wsa/wsa1"> <errorMessage xsi:type="xsd:string">msg=The server application returned the error: Invoice not found; targetException=ERROR condition: The Server application has returned an error. (7243) (7211)]</errorMessage> <requestID xsi:type="xsd:string">172247e5b58beb30:5bb966:fb4fdb744a:-7fff#9</requestID> </ns1:FaultDetail> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Accessing the SOAP-FAULT-DETAIL GET-NODE() GET-SERIALIZED() X-NODEREF LONGCHAR
Content used for SOAP-FAULT-DETAIL <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>An error was detected while executing the Web Service request. (10893)</faultstring> <detail> <ns1:FaultDetail SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://nberosenbe1:8080/wsa/wsa1"> <errorMessage xsi:type="xsd:string">msg=The server application returned the error: Invoice not found; targetException=ERROR condition: The Server application has returned an error. (7243) (7211)]</errorMessage> <requestID xsi:type="xsd:string">172247e5b58beb30:5bb966:fb4fdb744a:-7fff#9</requestID> </ns1:FaultDetail> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Lab 7-2: Handling a SOAP Fault
You should now be able to: Summary You should now be able to: Describe what a SOAP Fault is Describe the parts of a SOAP message Describe the elements of a SOAP Fault Implement the 4GL code to handle a SOAP Fault
Review