Scope
- Jobs can be implemented to access RESTful web services.
- A REST web service client is available for Scripting of Jobs and Monitors that are implemented with Java or JavaScript.
Implementation
- JITL provides a static Java class that can be used with Java and JavaScript. This class accepts a URL and returns an object in JSON syntax.
- For use with JavaScript the JSON object can be converted to a JavaScript object.
Methods
Method | Arguments | Description |
---|---|---|
com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService | execute a GET operation and return the result object | |
url | a URL that includes host and port of the web service, e.g. http://localhost:44445/jobscheduler/agent/api/ | |
com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand | execute a configurable operation and return the result object | |
operation | one of the HTTP verbs:
| |
url | a URL that includes host and port of the web service, e.g.http://localhost:44445/jobscheduler/agent/api/ | |
com.sos.jitl.restclient.JobSchedulerRestClient.getRestService | retrieve the web service object | |
host | hostname or ip address of the web service, e.g.
| |
port | port for which the web service is accessible, e.g. 4445 | |
path | path and query string of the web service URL, e.g.
| |
protocol | protocol in use including |
Integration with JavaScript
- Basically a web service call is implemented by executing one of the above methods from the JITL Java class:
var response = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://localhost:44445/jobscheduler/agent/api/" )
- The result object returned by the web service can be converted to a JavaScript JSON object by use of the
eval()
function:eval ( "var jsonObject = " + response + ";" );
- Properties of the JSON object can be accessed with the object hierarchy as provided by the web service like this:
jsonObject.system.hostname
Example
JavaScript sample for use with a job: this job requests the status information from the JobScheduler Universal Agent and returns the total number of tasks that have been executed during the Agents' lifetime: