Step 3: Write the MAIN program block
To explain how you code a Genero client application that accesses a SOAP Web service, this documentation uses the example of a calculator client application. This application accesses the Add operation in the MyCalculator Web service. To write the client, you simply need to access the WSDL for the Web service. To learn how to program the service, see Writing a Web server application.
Provide values for the input and output messages of the operation, and call one of the generated functions. Since the input and output messages are simple integers, we can call the Add function defined in the stub file (ws_calculator).
MAIN
  DEFINE op1        INTEGER
  DEFINE op2        INTEGER
  DEFINE result     INTEGER
  DEFINE wsstatus   INTEGER
  LET op1 = 1
  LET op2 = 2
  CALL ws_calculator.Add(op1, op2) RETURNING wsstatus, result
  IF wsstatus = 0 THEN
    DISPLAY "Result: ", result
  ELSE
    -- Use the wsError record
    DISPLAY "Error: ", wsError.description
  END IF
END MAIN
MAIN
  DEFINE wsstatus INTEGER
  LET ws_calculator.Add.a = 1
  LET ws_calculator.Add.b = 2
  LET wsstatus = ws_myStub.Add_g()
  IF wsstatus != 0 THEN
    -- Use the wsError record
    DISPLAY "Error :", wsError.Description
  ELSE
    DISPLAY "Result: ", AddResponse.r
  END IF
END MAINThese examples are very basic versions of the code. For complete examples, see the code samples provided with the package in demo/WebServices.
Backward compatibility for globals
GLOBALS
statement at the top of the .4gl module that links the stub file. This means
you can reference the variables and call the function directly. In the first code
sample you can change to this method to call the stub
function:# ...
CALL Add(op1, op2) RETURNING wsstatus, result
#...# ...
 LET Add.a = 1
 LET Add.b = 2
 LET wsstatus = Add_g()
#...