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 (where fglrun is executing).

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 above, 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

The following example uses the Process Services method of the WebServiceEngine class to process each incoming request, returning an integer representing the status. The parameter specifies the timeout period in number of 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."
    END CASE
    IF int_flag<>0 THEN
      LET int_flag=0
      EXIT WHILE
    END IF 
  END WHILE

  DISPLAY "Server stopped"

END MAIN
Note: The Genero Application Server (GAS) is required to manage your application in a production environment. For deployment, the GWS Server application must be added to the GAS configuration; see "Adding Applications" in the GAS manual. For testing purposes only, the GWS Server can be started in stand-alone mode.