Step 5: Start the GWS server and process requests

Once you have registered the Web Service(s), you are ready to start the Genero Web Services (GWS) Server and process the incoming SOAP requests.

The GWS Server is located on the same physical machine where the application is being executed (In other words, where fglrun executes).

This is the MAIN program block of your application.

Define a variable for status

Define a variable to hold the returned status of the request:
MAIN
  DEFINE ret INTEGER
Call the function that you created, which defined and registered the service and its operations:
  CALL createservice()

Start the GWS Server

Use the Start class method of the WebServiceEngine class to start the server.
  CALL com.WebServiceEngine.Start()

Process the requests

This example uses the ProcessServices method of the WebServiceEngine class to process each incoming request. It returns an integer representing the status. The parameter specifies the timeout period (in seconds) for which the method should wait to process a service. The value -1 specifies an infinite waiting time.
  WHILE TRUE
    # Process each incoming requests (infinite loop)
    LET ret = com.WebServiceEngine.ProcessServices(-1)
    CASE ret
      WHEN 0
        DISPLAY "Request processed."
      WHEN -1
        DISPLAY "Timeout reached."
      WHEN -2
        DISPLAY "Disconnected from application server."
        EXIT PROGRAM 
      WHEN -3
        DISPLAY "Client Connection lost."
      WHEN -4
        DISPLAY "Server interrupted with Ctrl-C."
      WHEN -10
        DISPLAY "Internal server error."
        EXIT PROGRAM
      WHEN -15
        DISPLAY "Server was not started."
        EXIT PROGRAM
      OTHERWISE
        DISPLAY "ERROR: ", STATUS, SQLCA.SQLERRM
    END CASE
    IF int_flag<>0 THEN
      LET int_flag=0
      EXIT WHILE
    END IF 
  END WHILE

  DISPLAY "Server stopped"

END MAIN
Note: For testing purposes only, the GWS Server can be started in standalone mode. In a production environment, the Genero Application Server (GAS) is required to manage your application. For deployment, the GWS Server application must be added to the GAS configuration. See Adding Applications in the Genero Application Server User Guide.