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 sample client application, a call to the function myWScall
updates a
user resource via a call to a client stub function.
In the function the variable this
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 client stub function. The variable is
passed in the call to the client stub function.
wsstatus
of typeINTEGER
for the error coderes
of typeSTRING
for details of the error that may be returned
CASE wsstatus
statement. If the status code is not equal to zero (clientStub.C_SUCCESS
),
details of the error are displayed in wsstatus
and res
.
For more information on handling errors in the response from a call to a service operation,
see Handle GWS REST server errors.IMPORT FGL clientStub
MAIN
CALL myWScall()
END MAIN
# Function performs call to the client stub function
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"
OTHERWISE
DISPLAY "Unexpected error :", wsstatus, res
END CASE
END FUNCTION
Find a client application at $FGLDIR/demo/WebServices/books.