Add ability to return custom object fields in SOAP faults returned from an OpenEdge SOAP web service - OpenEdge Development - Products Enhancements - Progress Community

 OpenEdge Development

Add ability to return custom object fields in SOAP faults returned from an OpenEdge SOAP web service

Currently, the Web Service Adapter, when generating a SOAP fault from a customised AppError object, will only return the standard AppError ReturnValue field.

It would be useful  for the fields in a serializable custom class based on the AppError class, to be returned in the SOAP fault, e.g. so that application specific error codes and messages could be returned in separate fields. See below for an example custom error class and webservice.

/* CustomError.cls */
USING Progress.Lang.*.

CLASS CustomErrors.CustomError INHERITS AppError SERIALIZABLE: 
    DEFINE PUBLIC PROPERTY ErrorCode AS CHARACTER NO-UNDO 
        GET. 
        SET.
END CLASS.

 

 

 

Comments
  • Here's the custom error class:

    /* CustomError.cls */

    USING Progress.Lang.*.

    CLASS CustomErrors.CustomError INHERITS AppError SERIALIZABLE:

       DEFINE PUBLIC PROPERTY ErrorCode AS CHARACTER NO-UNDO

           GET.

           SET.

    END CLASS.

  • Here's the test web service:

    USING PROGRESS.Lang.*.

    DEFINE INPUT  PARAMETER RequestData  AS CHARACTER NO-UNDO.

    DEFINE OUTPUT PARAMETER ResponseData AS CHARACTER NO-UNDO INITIAL "".        

    DEFINE VARIABLE gobj_AppError        AS CLASS CustomErrors.CustomError NO-UNDO.

    ASSIGN ResponseData = STRING(NOW).

    IF RequestData = "ERROR" THEN

    DO:

       gobj_AppError = NEW CustomErrors.CustomError().  

       gobj_AppError:AddMessage("Example Error Message", 1).  

       gobj_AppError:ReturnValue = gobj_AppError:GetMessage(1).

       gobj_AppError:ErrorCode = "E001".

       RETURN ERROR gobj_AppError.

    END.

    ELSE

    DO:

       IF RequestData <> ? THEN

           ASSIGN ResponseData = ResponseData + " Request data = " + RequestData.        

    END.