How to use operation handlers
- Last Updated: January 16, 2024
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
void
The
void operation handler returns only the status code
that is defined for the HTTP verb. This is useful in certain situations. For example,
when you want to reserve an endpoint for future enhancements (via a 501 - Not Implemented status code) or when you want to use
it to confirm that the server is alive (204 - No
Content). Use the void handler as
shown in this example:
"/CustomizedGreeting": {
"GET": {
"contentType": "application/json",
"statusCode": 501,
"void": null
}
}
file
The
file operation handler returns the contents of a
file, as long as the contents of the file conform to a supported MIME type. file operation handler to
work, the file must be placed within the web app directory, but not in the WEB-INF folder for security reasons. The static folder is the recommended location for it.
| Directory | Environment variable |
|---|---|
| PAS for OpenEdge instance root | ${env.CATALINA_BASE} |
| Web app directory (located in webapps in the PAS for OpenEdge instance root directory) | ${web.webapp} |
For example:
"/Message": {
"GET": {
"contentType": "application/json",
"statusCode": 200,
"file": "${env.CATALINA_BASE}/webapps/${web.webapp}/static/message.json"
}
}
entity
entity operation handler to map an HTTP
verb with an ABL procedure or an ABL class method. At runtime, when the verb is used
in an HTTP request to the service endpoint, the associated ABL procedure or class
method gets executed. entity, its use is not limited to ABL
Business Entities. You can use it to reference any ABL class or
procedure.Here is a simple example of the entity handler:
"/Greeting": {
"GET": {
"entity": {
"name": "Customer.Greeting",
"function": "getPersonalizedGreeting",
"arg": [
{
"ablName": "Cust-Name",
"ablType": "CHARACTER",
"ioMode": "INPUT",
"msgElem": {
"type": "query",
"name": "CustomerName"
}
},
{
"ablName": "GreetingMessage",
"ablType": "CHARACTER",
"ioMode": "OUTPUT",
"msgElem": {
"type": "field",
"name": "Message"
}
}
]
}
}
}
The name property identifies the ABL
class (Customer.Greeting) that is to be referenced;
the function property denotes the method (getPersonalizedGreeting) in the class that needs to be
invoked. The ioMode property identifies the
parameter type (INPUT, OUTPUT, etc).
The arg property (short for
arguments) is an array of JSON objects. Each object maps to an input or output
parameter that is required by the getPersonalizedGreeting method. The first three properties in each
arg object (ablName, ablType, and ioMode) identify the ABL parameter and correspond to
how the parameters are defined in the ABL method:
METHOD getPersonalizedGreeting(INPUT Cust-Name AS CHARACTER, OUTPUT
GreetingMessage AS CHARACTER):
...
END.
arg
object--msgElem--defines how the parameter
maps to a message element in the HTTP request or response. Parameters of the type
INPUT retrieve their values from message elements in HTTP requests. Parameters of
the type OUTPUT pass on their values (returned by the ABL method or procedure) to
message elements in HTTP responses. The msgElem
object therefore consists of two properties:- The
typeof message element in an HTTP request or response. Examples includequery,header, etc. - The
nameof the message element in an HTTP request or response. Examples includecustomer-id(for aquery), From, Host (for aheader), etc.
At runtime, the DOH uses these property mappings to convert HTTP
requests and responses into ABL objects. In some cases, such as for parameters that
are of the type INPUT-OUTPUT, you may need to map HTTP requests as well as HTTP
responses to the same parameter. In this case, you can use msgElem as an array as shown here:
"arg": [
{
"ablName": "CustomizedMessage",
"ablType": "CHARACTER",
"ioMode": "INPUT-OUTPUT",
"msgElem": [
{
"type": "query",
"name": "customer-name"
},
{
"type": "field",
"name": "message"
}
]
}
]
These examples illustrate a couple of different ways in which you can use the entity operation handler. The complete list of entity handler properties and the types of values that you can set for each property is described in the Entity Handler properties section.