Get system info by invoking REST webservice
# Instantiate a utility to handle IO #set($IOUtils = $ClassTool.newInstance("org.apache.commons.io.IOUtils")) # Instantiate a URL to the getInfo service of LogicalDOC #set($clazzUrl = $context.getClass().forName("java.net.URL")) #set($clazzString = $context.getClass().forName("java.lang.String")) # Adjust the url to point to your LogicalDOC installation #set($url = $clazzUrl.getConstructor($clazzString).newInstance("http://localhost:8080/services/rest/system/getInfo")) $log.info("url: $url") # Open the connection to the remote server #set ($con = $url.openConnection()) # Send a GET request and print the response status $con.setRequestMethod("GET"); #set ($status = $con.getResponseCode()) $log.info("status: $status") # Get the body of the response and store it in a variable #set ($result = '') #if ($status > 299) { #set ($result = $IOUtils.toString($con.getErrorStream(), "UTF-8")) #else #set ($result = $IOUtils.toString($con.getInputStream(), "UTF-8")) #end # Print the result $log.info("result: $result");
This procedure is designed to demonstrate the invocation of an external REST webservice method. It just invokes an URL and prints the result, in this case we use the endpoint of the System.getInfo REST webservice available in each LogicalDOC installation.
You replace the http://localhost:8080 with the base URL of your instalaltion.