Call the stub functions

The service information obtained from the REST Web Service allows you to write client applications that use the service.

The information in the specification file about 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.

Using parameters and return values

To call a function in your client application, you must define variables for its input parameters and return values. These, for example, may be simple types or user-defined records.

Details for what you need to define for these variables can be obtained from the OpenAPI specification file (see Generate service description on demand ) or from the generated function in the stub file.

Returns record type

TYPE add RECORD 
    a INT,
    b INT,
    c INT 
 END RECORD

Calling a stub function

IMPORT FGL clientStub

FUNCTION myWScall()
    DEFINE op1 INTEGER
    DEFINE op2 INTEGER

    DEFINE result add
    DEFINE wsstatus INTEGER

    LET op1 = 6
    LET op2 = 8
    CALL clientStub.Add(op1, op2) RETURNING wsstatus, result

    CASE wsstatus
        WHEN clientStub.C_SUCCESS
            DISPLAY "Addition result :", result.*
        OTHERWISE
            DISPLAY "Unexpected error :", wsstatus
    END CASE
END FUNCTION

The demo/WebServices subdirectory of your Genero installation directory contains complete examples of client applications.