...
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:
POST|PUT can be parameterized with the body
| |
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.
| |
body | The body for the POST | |
com.sos.jitl.restclient.JobSchedulerRestClient.putRestService | execute the web service operation using PUT | |
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.
| |
body | The body for the PUT | |
com.sos.jitl.restclient.JobSchedulerRestClient.setProxy | set Http proxy without credentials | |
proxyHost | hostname or ip address of the http proxy | |
proxyPort | port of the http proxy | |
com.sos.jitl.restclient.JobSchedulerRestClient.setProxy | set Http proxy with credentials if necessary | |
proxyHost / proxyPort | see setProxy without credentials | |
proxyUser | user of the http proxy if necessary | |
proxyPassword | user's password of the http proxy if necessary |
Adding Header items
- The header "Accept=application/json" will automatically be added.
- You can add header items with
com.sos.jitl.restclient.JobSchedulerRestClient.headers.put("header","value");
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<job stop_on_error="no" > <params/ > <script language="java:javascript"> <![CDATA[ function spooler_process() { //Set proxy if necessary // com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "proxyHost", proxyPort <params/ > <script language="java:javascript"> <![CDATA[ function spooler_process() { ); //or with credentials // com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "proxyHost", proxyPort, "proxyUser", "proxyPassword" ); //Getting the name of a person var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://www.thomas-bayer.com/sqlrest/CUSTOMER/18/" ); spooler_log.info( s ); var xmlDOM = new Packages.sos.xml.SOSXMLXPath( new java.lang.StringBuffer( s ) ); spooler_log.info( "Firstname is " + xmlDOM.selectSingleNodeValue( "//CUSTOMER/FIRSTNAME" )); //Creating a person with post com.sos.jitl.restclient.JobSchedulerRestClient.headers.put("Content-Type", "application/xml"); var post = "post(<resource><ID>4711</ID><LASTNAME>world</LASTNAME><FIRSTNAME>Hello</FIRSTNAME></resource>)"; var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand(post, "http://www.thomas-bayer.com/sqlrest/CUSTOMER/" ); //Reading the new entry var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711/" ); var xmlDOM = new Packages.sos.xml.SOSXMLXPath( new java.lang.StringBuffer( s ) ); spooler_log.info( "Name is " + xmlDOM.selectSingleNodeValue( "//CUSTOMER/FIRSTNAME" ) + " " + xmlDOM.selectSingleNodeValue( "//CUSTOMER/LASTNAME" )); //Changing the name com.sos.jitl.restclient.JobSchedulerRestClient.headers.put("Content-Type", "application/xml"); var post = "post(<resource><FIRSTNAME>Uwe</FIRSTNAME></resource>)"; var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand(post, "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711/" ); //Reading the name var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://www.thomas-bayer.com/sqlrest/CUSTOMER/18/" ); var xmlDOM = new Packages.sos.xml.SOSXMLXPath( new java.lang.StringBuffer( s ) ); spooler_log.info( "Firstname is " + xmlDOM.selectSingleNodeValue( "//CUSTOMER/FIRSTNAME" )); //Deleting the new entry com.sos.jitl.restclient.JobSchedulerRestClient.headers.put("Content-Type", "application/xml"); var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand("delete", "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711/" ); //Reading the deleted entry var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711/" ); spooler_log.info( s); //Creating a person with put com.sos.jitl.restclient.JobSchedulerRestClient.headers.put("Content-Type", "application/xml"); var put = "put(<resource><LASTNAME>world</LASTNAME><FIRSTNAME>Hello</FIRSTNAME></resource>)"; var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand(put, "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711" ); //Reading the new entry var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711/" ); var xmlDOM = new Packages.sos.xml.SOSXMLXPath( new java.lang.StringBuffer( s ) ); spooler_log.info( "Name is " + xmlDOM.selectSingleNodeValue( "//CUSTOMER/FIRSTNAME" ) + " " + xmlDOM.selectSingleNodeValue( "//CUSTOMER/LASTNAME" )); //Deleting the new entry com.sos.jitl.restclient.JobSchedulerRestClient.headers.put("Content-Type", "application/xml"); var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestServiceCommand("delete", "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711/" ); //Reading the deleted entry var s = com.sos.jitl.restclient.JobSchedulerRestClient.executeRestService( "http://www.thomas-bayer.com/sqlrest/CUSTOMER/4711/" ); spooler_log.info( s); return false; } ]]> </script> <run_time /> </job> |
...