setRestResponse

The system function serviceLib.setRestResponse allows an EGL Java REST Service to set a custom HTTP response depending on the business logic.

Syntax

serviceLib.setRestResponse(response HttpResponse in)

The invocation sets the REST HTTP response using the Record part HttpResponse, which is provided for you and has the following fields:

body, type STRING?

The response body to be returned from the service;

  • body contains the value in one of three formats (XML, JSON, or NONE), as described in “REST for the developer.”
    • If body is not specified, then the value of body will be the function response in one of three formats (XML, JSON, or NONE)
headers, type Dictionary
headers contains a set of name-value pairs. Each entry key in the dictionary is the name of an HTTP header that is to be returned from the service, and the related value (a string) is the value of that header.
status, type INT
status contains the HTTP status code for the response. If status is not specified, then the value 200 is used.

Important status codes include 200 (OK) and 404 (Not Found). For a complete list, go to the website of the World Wide Web Consortium (http://www.w3.org/) and search for "HTTP status code."

statusMessage, type STRING
statusMessage contains the HTTP status message for the response. If statusMessage is not specified, then the value OK is used.

Important status messages include OK (code 200) and Not Found (code 404). For a complete list, go to the website of the World Wide Web Consortium (http://www.w3.org/) and search for "HTTP status code."