DEFINE VARIABLE hWS AS HANDLE.
DEFINE VARIABLE hWebSrvc AS HANDLE NO-UNDO. DEFINE VARIABLE hPortType AS HANDLE NO-UNDO. DEFINE VARIABLE hSOAPFault AS HANDLE NO-UNDO. DEFINE VARIABLE hSOAPFaultDetail AS HANDLE NO-UNDO. DEFINE VARIABLE i AS INTEGER NO-UNDO. DEFINE VARIABLE cResponse AS CHARACTER NO-UNDO. DEFINE VARIABLE hRequest AS HANDLE NO-UNDO. CREATE SERVER hWebSrvc. hWebSrvc:CONNECT("-pf soap.pf"). RUN ErrorServiceSoap SET hPortType ON hWebSrvc. /* Get a SOAP fault */ /* HelloWorld2 always throws an exception with detailed contents. */ RUN HelloWorld2 IN hPortType ASYNCHRONOUS SET hRequest EVENT-PROCEDURE "procDone" IN THIS-PROCEDURE (OUTPUT cResponse). WAIT-FOR PROCEDURE-COMPLETE OF hRequest. DELETE OBJECT hRequest. DELETE OBJECT hPortType. hWebSrvc:DISCONNECT(). DELETE OBJECT hWebSrvc. PROCEDURE procDone: DEFINE INPUT PARAMETER cResponse AS CHARACTER. DEFINE VARIABLE myerr AS Progress.Lang.Error. DEFINE VARIABLE soaperr AS Progress.Lang.SoapFaultError. IF hRequest:ERROR THEN DO: MESSAGE "An error occurred when running HelloWorld2". /*1*/ myerr = SELF:ERROR-OBJECT. /*2*/ soaperr = CAST (myerr, Progress.Lang.SoapFaultError). /*3*/ IF soaperr:NumMessages > 0 THEN DO: DO i = 1 TO soaperr:NumMessages: MESSAGE "SoapFault Error: " soaperr:GetMessage(i). END. /*4*/ IF VALID-HANDLE(soaperr:SoapFault) THEN DO: MESSAGE "soaperr:SOAPFAULT is a valid handle". hSOAPFault = soaperr:SoapFault. MESSAGE "Fault Code: " hSOAPFault:SOAP-FAULT-CODE SKIP "Fault String: " hSOAPFault:SOAP-FAULT-STRING SKIP "Fault Actor: " hSOAPFault:SOAP-FAULT-ACTOR SKIP "Error Type: " hSOAPFault:TYPE SKIP. /*5*/ IF VALID-HANDLE(hSOAPFault:SOAP-FAULT-DETAIL) THEN DO: SOAPFaultDetail = hSOAPFault:SOAP-FAULT-DETAIL. END. END. END. END. END PROCEDURE. |