|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deegree.protocol.wps.client.WPSClient
public class WPSClient
API-level client for accessing services that implement the WebProcessingService (WPS) 1.0.0 protocol.
WPSClient
instance by invoking the
constructor with a URL to a WPS capabilities document. In most cases, this will be a GetCapabilities request
(including necessary parameters) to a WPS service.
... URL capabilitiesUrl = new URL( "http://...?service=WPS&version=1.0.0&request=GetCapabilities" ); WPSClient wpsClient = new WPSClient( capabilitiesUrl ); ...Afterwards, the
WPSClient
instance is bound to the specified service and allows to access announced service
metadata, process information as well as the execution of processes.
getMetadata()
allows to access the metadata announced by the
service, such as title, abstract, provider etc.
getProcesses()
allows to find out about the processes
offered by the service. Additionally (if one knows the identifier of a process beforehand), one can use
getProcess(String)
or getProcess(String, String)
to retrieve a specific process. The
Process
class allows to execute a process and offers methods to access detail information such as title,
abstract, input parameter types and output parameters types:
... Process buffer = wpsClient.getProcess ("Buffer"); System.out.println ("Abstract for Buffer process: " + buffer.getAbstract()); System.out.println ("Number of input parameters: " + buffer.getInputTypes().length); System.out.println ("Number of output parameters: " + buffer.getOutputTypes().length); ...
Process.prepareExecution()
must be used to
create a ProcessExecution
context first. This context provides methods for setting the input parameters,
controlling the desired output parameter behaviour and invoking the execution.
... Process buffer = wpsClient.getProcess ("Buffer"); // get execution context ProcessExecution execution = buffer.prepareExecution(); // add input parameters execution.addLiteralInput( "BufferDistance", null, "0.1", "double", "unity" ); execution.addXMLInput( "GMLInput", null, gmlFileUrl, "text/xml", null, null ); // perform execution ExecutionOutputs outputs = execution.execute(); // access individual output values ComplexOutput bufferedGeometry = outputs.getXML ("BufferedGeometry", null); XMLStreamReader xmlStream = bufferedGeometry.getAsXMLStream(); ...
AbstractProcessExecution.addLiteralInput(String, String, String, String, String)
respectively AbstractProcessExecution.addBBoxInput(String, String, double[], double[], String)
... execution.addLiteralInput( "BufferDistance", null, "0.1", "double", "unity" ); execution.addBBoxInput( "BBOXInput", null, new double[] { 0, 0 }, new double[] { 90, 180 }, "EPSG:4326" ); ...For complex data however, the are methods that provide XML and binary data separately. One can provide the input as reference by giving an URL and whether it is external (using http, ftp, etc. protocols) or local (file protocol).
AbstractProcessExecution.addXMLInput(String, String, URL, boolean, String, String, String)
and
respectively AbstractProcessExecution.addBinaryInput(String, String, URL, boolean, String, String)
... URL externalURL = new URL( "http://..." ); execution.addXMLInput( "XMLInput1", null, externalURL, true, "text/xml", null, null ); URL localURL = new URL( "file:/home/musterman/xmlInput.xml" ); execution.addXMLInput( "XMLInput2", null, localURL, false, "text/xml", null, null ); // and for binary data, as local file execution.addBinaryInput( "BinaryInput1", null, localBinaryURL, false, "image/png", null ); // OR, from the web execution.addBinaryInput( "BinaryInput2", null, externalBinaryURL, true, "image/png", null ); ...Alternatively, one can simply provide the input inline as stream. In the case of XML it will be a
XMLStreamReader
, while for the binary data expected will be an InputStream
.AbstractProcessExecution.addXMLInput(String, String, XMLStreamReader, String, String, String)
respectively AbstractProcessExecution.addBinaryInput(String, String, java.io.InputStream, String, String)
... execution.addXMLInput( "XMLInput", null, reader, "text/xml", null, null ); // respectively, in the case of binary input execution.addBinaryInput( "BinaryInput", null, is, "image/png", null ); ...
ProcessExecution.addOutput(String, String, String, boolean, String, String, String)
and specifying the id of
the respective wanted output. Among the parameters there is the possibility of specifying to retrieve the output
as reference or inline.
... // BBOXOutput will be returned inline execution.addOutput( "BBOXOutput", null, null, false, null, null, null ); // BinaryOutput will be returned as reference execution.addOutput( "BinaryOutput", null, null, true, null, null, null ); // the other (not specified) outputs will be skipped. ...
RawOutput
mode, where the (single) output parameter is not going to be wrapped in an ExecuteResponse XML
document, but directly returned as a resource. For this one must set Process.prepareRawExecution()
to
retrieve a suitable execution context. The server shall respond with this sole output resource.
... Process buffer = wpsClient.getProcess ("Buffer"); // get raw execution context RawProcessExecution execution = buffer.prepareRawExecution(); // add input parameters execution.addLiteralInput( "BufferDistance", null, "0.1", "double", "unity" ); execution.addXMLInput( "GMLInput", null, gmlFileUrl, "text/xml", null, null ); // invoke RawOutput mode execution (returns a single output parameter) ComplexOutput output = execution.execute("GMLOutput", null, "text/xml", null, null); ...
ProcessExecution.execute()
, one can also
request asynchronous execution via the ProcessExecution.executeAsync()
method. In the latter case, the call
will return immediately, but the result is not necessarily available yet. In order to check for completion, the
ProcessExecution.getState()
is available, that will poll the server for the current status (if it wasn't
finished anyway). Additionally, the method ProcessExecution.getPercentCompleted()
is available to check the
execution progress (if the process supports it).
... Process buffer = wpsClient.getProcess ("Buffer"); // get execution context ProcessExecution execution = buffer.prepareExecution(); // add input parameters execution.addLiteralInput( "BufferDistance", null, "0.1", "double", "unity" ); execution.addXMLInput( "GMLInput", null, gmlFileUrl, "text/xml", null, null ); // invoke asynchronous execution (returns immediately) execution.executeAsync(); // do other stuff ... // check execution state if (execution.getState() == SUCCEEDED) { ExecutionOutputs outputs = execution.getOutputs(); ... // access the outputs as in synchronous case ComplexOutput bufferedGeometry = outputs.getXML ("BufferedGeometry", null); XMLStreamReader xmlStream = bufferedGeometry.getAsXMLStream(); } ...
WPSClient
instance can be shared among multiple threads.GetCapabilities
and DescribeProcess
requests.ProcessExecution
.
Process
,
ProcessExecution
Constructor Summary | |
---|---|
WPSClient(URL capabilitiesURL)
Creates a new WPSClient instance. |
Method Summary | |
---|---|
URL |
getDescribeProcessURL(boolean post)
Returns the URL announced by the service for issuing DescribeProcess requests. |
URL |
getExecuteURL(boolean post)
Returns the URL announced by the service for issuing Execute requests. |
OWSCapabilities |
getMetadata()
Returns the metadata (ServiceIdentification, ServiceProvider) of the service. |
Process |
getProcess(String id)
Returns the specified process instance (ignoring the codespace of the identifier). |
Process |
getProcess(String id,
String idCodeSpace)
Returns the specified process instance. |
Process[] |
getProcesses()
Returns all processes offered by the service. |
String |
getServiceVersion()
Returns the WPS protocol version in use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WPSClient(URL capabilitiesURL) throws OWSExceptionReport, IOException
WPSClient
instance.
capabilitiesURL
- url of a WPS capabilities document, usually this is a GetCapabilities request to a WPS service, must
not be null
OWSException
- if the server replied with an exception
IOException
- if a communication/network problem occured
OWSExceptionReport
Method Detail |
---|
public String getServiceVersion()
NOTE: Currently, this is always "1.0.0" (as the client only supports this version).
null
public OWSCapabilities getMetadata()
null
public Process[] getProcesses()
null
public Process getProcess(String id)
NOTE: This is a convenience method that ignores the optional codespace that a process identifier may have. If a
server actually offers two processes with the same identifier, but different codespace, let's say 'Buffer'
(codespace: 'Sextante') and 'Buffer' (codespace: 'GRASS'), then it's not defined which of the ones will be
returned, when this method is called with parameter 'Buffer'. To be on the safe side, use
getProcess(String, String)
.
id
- process identifier, never null
null
(if no process with the specified identifier and code space is
offered by the services)public Process getProcess(String id, String idCodeSpace)
id
- process identifier, never null
idCodeSpace
- codespace of the process identifier, may be null
(for identifiers that don't use a code
space)
null
(if no process with the specified identifier and code space is
offered by the services)public URL getDescribeProcessURL(boolean post)
DescribeProcess
requests.
post
- if set to true, the URL for POST requests will be returned, otherwise the URL for GET requests will be
returned
DescribeProcess
URL, may be null
(if the server doesn't provide a binding
for the specified request method)public URL getExecuteURL(boolean post)
Execute
requests.
post
- if set to true, the URL for POST requests will be returned, otherwise the URL for GET requests will be
returned
Execute
URL, may be null
(if the server doesn't provide a binding for the
specified request method)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |