Client / Client stub and handlers |
The information obtained from the ws_calculator.inc file allows you to write code in your own .4gl module as part of the Client application, using the Web Service operation Add.
FUNCTION myWScall() DEFINE op1 INTEGER DEFINE op2 INTEGER DEFINE result INTEGER DEFINE wsstatus INTEGER ... LET op1 = 6 LET op2 = 8 CALL Add(op1, op2) RETURNING wsstatus, result ... DISPLAY result
FUNCTION myWScall() DEFINE wsstatus INTEGER ... LET Add.a = 6 LET Add.b = 8 LET wsstatus = Add_g() ... DISPLAY AddResponse.r
In this case, the status is returned by the function, which has also put the result in the AddResponse global record.
See Tutorial: Writing a Client Application for more information. The demo/WebServices subdirectory of your Genero installation directory contains complete examples of Client Applications.
FUNCTION sendMyWScall() DEFINE wsstatus INTEGER ... LET Add.a = 6 LET Add.b = 8 LET wsstatus = AddRequest_g() IF wstatus <> 0 THEN DISPLAY "ERROR :", wsError.code END IF ...
FUNCTION retrieveMyWScall() DEFINE wsstatus INTEGER ... LET wsstatus = AddResponse_g() CASE wstatus WHEN -2 DISPLAY "No response available, try later" WHEN 0 DISPLAY "Response is :",AddResponse.r OTHERWISE DISPLAY "ERROR :", wsError.code END CASE ...
You can mix the asynchronous call with the synchronous one as they are using two different requests. In other words, you can perform an asynchronous request with AddRequest_g, then a synchronous call with Add_g, and then retrieve the response of the previous asynchronous request with AddResponse_g.