com.WebServiceEngine.GetHTTPServiceRequest

Get a handle for an incoming HTTP service request.

Syntax

com.WebServiceEngine.GetHTTPServiceRequest(
   timeout INTEGER)
  RETURNS com.HttpServiceRequest
  1. timeout defines the timeout in seconds.

Usage

The com.WebServiceEngine.GetHTTPServiceRequest() class method returns a com.HttpServiceRequest object to handle an incoming HTTP request, or NULL if there was no request during the given period of time.

The timeout parameter defines the time in seconds to wait for an incoming request. A value of -1 means infinite wait. When the timeout occurs, the method returns NULL.

In case of error, the method throws an exception and sets the status variable. Depending on the error, a human-readable description of the problem is available in the sqlca.sqlerrm register. See Error handling in GWS calls (status).

Any new call to this function will raise an error until the previous HTTP request is handled by sending a response back to the client, or destroyed.

The error -15565 can be thrown if an invalid or unsupported HTTP request is sent. Supported methods are GET, PUT, POST, HEAD, and DELETE.

Even if the exception is trapped, the GWS HTTP server is not in a valid state anymore, and you must close the application properly before exiting the program.
Note:

This is not an issue in production environments as the Genero Application Server (GAS) and GWSProxy will detect the ended DVM, return an HTTP error code to the client app, and any new request will start a new DVM in a clean state via GWS proxy and the pool configuration.

The error -15575 can be thrown if the GAS disconnects the Web Services program.

URLs are sent in UTF-8 on the network, if the web services server is not able to convert UTF-8 URLs back to fglrun locale charset, error -15552 will be thrown. As a general advice, run you WS server program in UTF-8.

Example

DEFINE req com.HttpServiceRequest
...
TRY 
  WHILE TRUE
    LET req = com.WebServiceEngine.getHTTPServiceRequest(-1)
    IF req IS NULL THEN
      DISPLAY "HTTP request timeout...: ", CURRENT YEAR TO FRACTION
    ELSE
      CALL req.sendTextResponse(200,NULL,"It works")
    END IF
  END WHILE
CATCH 
  IF status == -15575 THEN
    DISPLAY "Disconnected : ",sqlca.sqlerrm
  ELSE
    DISPLAY "ERROR : ",status,sqlca.sqlerrm
  END IF
END TRY
...