REST stub file overview
The stub file acts as a proxy to the Web service, making it easy to use a Web service in your client app.
The fglrestful tool can generate a stub file
(.4gl) for access by a Genero Web Services (GWS) client application for any
REST Web service supporting the OpenAPI specification. It creates functions in Genero BDL that
perform requests and return responses and data from the Web service. The functions in the client
stub implement the standard low-level API HTTP classes of the
com
package of the GWS.
The stub file defines data types for the input and output records matching those generated on the server side. In your Web service client app, you create calls to the stub file functions to perform operations on the resources of the Web service.
Reference records
You will find details for the parameters and return values to use with functions from the OpenAPI description (see Generate service description on demand ) or from the generated functions in the stub file.
In your client app, you must import the stub file using an IMPORT FGL
statement.
It is recommended that you reference types using their fully-qualified names in case the same name
exists in different modules.
Using stub files
This example shows how data types and functions defined for a Web service created with Genero BDL, are generated in the stub file, and called by the client accessing the Web service.
Study this example to learn how to use the stub file in your Genero client application.
Server
PUBLIC TYPE recType RECORD
idtype SMALLINT,
nametype STRING
END RECORD
PUBLIC FUNCTION echoRec(
IN recType)
ATTRIBUTE(WSPost, WSPath = "/testTypeRec", WSRetCode = "202:Accepted")
RETURNS(recType)
DEFINE OUT recType
LET OUT = in
RETURN out.*
END FUNCTION
Stub file (ws_stub)
# components/schemas/recType
PUBLIC TYPE recType RECORD
idtype INTEGER,
nametype STRING
END RECORD
PUBLIC FUNCTION echoRec(
p_body recType)
RETURNS(INTEGER, recType)
# ... function code
END FUNCTION
Client
IMPORT FGL ws_stub
DEFINE wsstatus STRING
FUNCTION test()
DEFINE IN, OUT ws_stub.recType
LET in.idType = 1
LET in.nameType = "test STRING"
CALL ws_stub.echoRec(in.*) RETURNING wsstatus, out.*
# ... function code
END FUNCTION