Step 3: Create service, start server and process requests
Code to start the Genero Web Services (GWS) Server.
Create your own
MAIN
module that calls the function from the generated
.4gl file to create the service, then starts the Genero Web Services Server and
manages requests as in Step 5: Start the GWS server and process requests of
Example 1: Writing the entire server application.# example2main.4gl file -- contains the MAIN program block
IMPORT com
IMPORT FGL example1Service -- import the generated service file
MAIN
DEFINE create_status INTEGER
-- call the function generated in example1Service.4gl
CALL example1Service.Createexample1Service()
RETURNING create_status
IF create_status <> 0 THEN
DISPLAY "error"
ELSE
# Start the server and manage requests
CALL ManageService()
END IF
END MAIN
FUNCTION ManageService()
DEFINE ret INTEGER
CALL com.WebServiceEngine.start()
WHILE TRUE
# continue as in Step 5 of Example 1
...
END FUNCTION
Backward compatibility for globals
If you have generated stub
files for compatibility with your GWS client app, you have a reference in the
GLOBALS
statement at the
top of the .4gl module that links the stub file.
# example2main.4gl file -- contains the MAIN program block
IMPORT com
GLOBALS "example1Service.inc" -- use the generated globals file
MAIN
DEFINE create_status INTEGER
CALL Createexample1Service() -- call the function generated in example1Service.4gl
# continue as in the example above
# ...