Call the stub functions
Call the functions defined in the client stub to interact with the REST service from your application code.
The client stub provides the functions and record types that your application uses to call the REST service. This topic shows how to call a stub function from a client module.
Calling a stub function in the client application
In this example, the function myWScall updates a user resource by calling a function provided in the client stub.
The variable this is defined as a stub-generated record type (clientStub.addUserRequestBodyType). Values are assigned to the fields before calling the stub function.
Two variables are defined for the return:
wsstatusof typeINTEGERfor the status coderesof typeSTRINGfor details returned by the service
The response is evaluated in a CASE statement. If wsstatus is not equal to clientStub.C_SUCCESS, the error details are displayed. For more details about handling errors, go to 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 complete client application at $FGLDIR/demo/WebServices/books.