Call the stub functions

Functions in the stub file allows you to write code in your own .4gl module that calls these functions as part of your client application.

The service information obtained from the REST Web Service provides information about using the service.

Calling a stub function in the client app

In this example the this variable is defined as a record type based on a user-defined record in the client stub, clientStub.addUserRequestBodyType.

Values are passed to the variable before calling the function.

Variables are defined for the return code (wsstatus) and for error details returned by the call (res). See Handle GWS REST server errors.

IMPORT FGL clientStub

FUNCTION myWScall()
    DEFINE this clientStub.addUserRequestBodyType
    DEFINE wsstatus INTEGER
    DEFINE res STRING

    LET this.user_name= "Mike Pantock"
    # ...
  
    CALL clientStub.addUser(this.*)RETURNING wsstatus, res
    CASE wsstatus
       WHEN clientStub.C_SUCCESS
         DISPLAY "Success adding new user"
       # … function code
       OTHERWISE
         DISPLAY "Unexpected error :", wsstatus, res
    END CASE
    
END FUNCTION

Find a client application at $FGLDIR/demo/WebServices/books.