Write the MAIN program code block

Create the MAIN program block that imports the client stub and calls its functions.

After generating the client stub for the REST service, write the MAIN program block that performs the calls to the service functions.

In your MAIN module, you:

  1. Import the client stub module.
  2. If the service requires authentication, obtain the access token before calling any functions. See Main program code for access to secure service
  3. Call the functions provided by the stub.
IMPORT FGL clientStub
MAIN
  DEFINE wsstatus INTEGER
  DEFINE rets STRING
  DEFINE opt1 INTEGER
  LET opt1=22
  CALL clientStub.getUsersName(opt1) RETURNING wsstatus, rets
  IF wsstatus = clientStub.C_SUCCESS THEN
    DISPLAY "User name is :",rets
  ELSE
    DISPLAY "Error in getting user details"
  END IF
END MAIN

This example is a basic version of the code. For a complete client application, see $FGLDIR/demo/WebServices/books.