WPSClient
1. Motivation
The goal is to provide an easy-to-use API (as part of deegree 3) that makes communication with an arbitrary WPS server dead simple and fail-safe. A user of the API would basically just need to create a new instance of the WPSClient class, providing the URL of the server. Afterwards, all actions (getting process/server metadata, executing processes, retrieving the results, ...) should be just a matter of invoking the appropriate methods.
Basically, the WPSClient should be for the WPS protocol what the well-known Apache Commons HttpClient is for the HTTP protocol.
The interaction between a WPS service is solely based on Java objects, there is no need to define lengthy XML snippets anymore to access your WPS server.
To follow the next steps, the easiest way is to set up a local development environment based on our maven deegree-api-example environment.
2. Interacting with the deegree WPSClient API
The major design goal for the WPSClient API is simplicity. WPSClient will assist you in formulating simple requests against a WPS-Server, e.g. like transmitting literal values, but it also allows you to provide multiple complex inputs, running remote services asynchronously and polling for status information.
The main class to interact with is org.deegree.protocol.wps.client.WPSClient.
To initialize an WPSClient-Object, you need to provide an URL to a WPS server, like http://deegree3-testing.deegree.org/deegree-wps-demo/services?service=WPS&request=GetCapabilities
If we do not care about proper exception handling (and we do not care here), initializing a WPSClient object is a matter of two lines of code:
URL wpsUrl = new URL("http://deegree3-testing.deegree.org/deegree-wps-demo/services?service=WPS&request=GetCapabilities");
WPSClient wpsClient = new WPSClient(wpsUrl);
The instance wpsClient is your connection to the WPS server and the main object to interact with. Usually, when interacting with OGC webservices, you follow the three steps:
Get the servers capabilities/metadata (using the GetCapabilities interface)
- Get a detailed description of the available featureTypes, records and in this case, processes
Do the actual work, e.g. get a FeatureCollection, a set of records or perform a process execution
2.1. GetCapabilities
Capabilities-responses are not that interesting from a programming point-of-view since they usually contain loads of metadate about the service provider like contact details. The most interesting part within the Capabilities-repsonse in the case of Web Processing Service is the section containing the process identifiers, since this section contains the necessary information to obtain proper process descriptions. Nevertheless, if you are interested in service metadata, you need to retrieve a org.deegree.protocol.ows.metadata.ServiceMetadata object. This is placed outside the WPS package structure since this object is reusable for any kind of OGC webservice. To obtain a ServiceMetadata object from the WPS Client, just call the corresponding getter-Method and assign the result to a ServiceMetadata object:
ServiceMetadata smd = wpsclient.getMetadata();
Now you can interrogate the ServiceMetadata object to get further information like version, service identification, operations metadata, etc.
The more interesting stuff to perform a subsequent describe process call is also very easy to get:
// get the describeProcessURL using get (therefor false as parameter)
java.net.URL describeProcessURL = wpsclient.getDescribeProcessURL( false );
// get all available Processes as an array of Process
org.deegree.protocol.wps.client.process.Process[] arrayOfProcesses = wpsclient.getProcesses();
// get a specific process as identified by its name, e.g. buffer
org.deegree.protocol.wps.client.process.Process bufferProcess = wpsclient.getProcess( "buffer" );
2.2. DescribeProcess