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.
- This feature is provided with - JITL-213Getting issue details... STATUS
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.
- The header "Accept=application/json" will automatically be added.
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 | execute the web service operation using GET | |
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 | |
com.sos.jitl.restclient.JobSchedulerRestClient.postRestService | execute the web service operation using POST | |
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.
|
Integration with JavaScript
- Basically a web service call is implemented by executing one of the above methods from the JITL Java class, e.g.:
var response = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://localhost:44445/jobscheduler/agent/api/" );
var response = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand( "get", "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 within the object hierarchy provided by the web service result object like this:
jsonObject.system.hostname
Example
- JavaScript example 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. This job reads the web service URL from a job parameter.
- Download: rest_client.job.xml
References
Change Management References
Documentation