The PING service allows an ABL client to interrogate the state of a data service (online or offline) and the ABL application's ability to respond. It can be used in conjunction with other static service resources (such as /static/home.html), and the HTTP status to isolate whether the server, service, transport, and ABL application are available for use.
The APSV, REST, and WEB transports use the ServerStatus ( ) method of the OpenEdge.Rest.Admin.AppServerStatus class to implement the PING service. You can extend the class to return application-specific information about database connections, PROPATH, loaded libraries, caches, available services, and more.:
Note: The PING service is not available for the SOAP transport.
Transport Syntax
REST
GET { http | https }://host:port/web_app/rest/_oepingService/_oeping
WEB
GET { http | https }://host:port/web_app/web/_oepingService/_oeping
To enable the PING service for the WEB transport, you must configureOpenEdge.Web.PingWebHandler in the openedge.properties file. For example:
handlern
Note: You can configure the handler to be something other than =OpenEdge.Web.PingWebHandler: /_oeping /_oepingService/_oeping. The ping service will only respond to the exact URL as configured in the openedge.properties file. For example, if the OpenEdge.Web.PingWebHandler is mapped to /ping then a client must call instance/web-app/web/ping in order for the ServerStatus( ) =OpenEdge.Web.PingWebHandler: /_oeping method to be called.
APSV
Run OpenEdge/ApplicationServer/Util/apsv_oeping.p on happsrv(OUTPUT
JSON_Data).
where happsrv is the application server handle andJSON_Data is the JSON output,
JSON output format
When a PING is successful, it can return a JSON array with the following information:
{“response”: {“_retVal”: “text” }}
No return to a PING indicates that the agent is available, since the default value for text is blank (" ").
To customize the return value, extract the OpenEdge.Rest.Admin.AppServerStatus class from the oe-install-dir/src/OpenEdge.ServerAdmin.pl procedure library and place the customized version in your PROPATH.
If a PING is not successful, it returns a JSON array with the following information:
Note that the error message may include additional properties,
Securing the PING service
You can restrict access to the PING service in the /web-app/WEB-INF/oeablSecurity.csv file. For example, to restrict everyone from accessing REST PING, add the line in bold:
############## Intercept-url definitions for the REST transport URIs###############
"/rest/_oepingService/_oeping",”*”,"denyAll()" "/rest/**","*","hasAnyRole('ROLE_PSCAdmin')"
###################################
Note: Order is important. The line with denyAll(), which restricts access to PING, must appear before the following line, which allows access to all REST services.
Example
The following code returns server status that includes the names of connected databases and PROPATH entries.
method public character ServerStatus( ):
define variable statusJson as JsonObject no-undo.
define variable dataArray as JsonArray no-undo.
define variable svrStatus as character no-undo.
define variable cnt as integer no-undo.
define variable maxCnt as integer no-undo.
assign statusJson = new JsonObject().
dataArray = new JsonArray().
statusJson:Add('ldb',dataArray).
do cnt = 1 to num-dbs:
dataArray:Add(ldbname(cnt)).
end.
assign maxCnt = num-entries(propath)
dataArray = new JsonArray().
statusJson:Add('propath', dataArray).
do cnt = 1 to maxCnt:
dataArray:Add(entry(cnt, propath)).
end.
statusJson:Write(output svrStatus).
return svrStatus.
end.
The output from the example code would look similar to the following