Testing the PyWPS and first process

The very first test can be done in the command line. Before we start, several environment variables have to be set:

export PYWPS_PROCESSES=/usr/local/processes/
export PYWPS_CFG=/usr/local/processes/pywps.cfg

GetCapabilities

Now we can run the wps.py binary from the command line:

/usr/local/pywps/wps.py "service=wps&request=getcapabilities"

You should obtain following text.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="utf-8"?>
<wps:Capabilities service="WPS" version="1.0.0" xml:lang="eng" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsGetCapabilities_response.xsd" updateSequence="1">
	<ows:ServiceIdentification>
		<ows:Title>PyWPS Server</ows:Title>
		<ows:Abstract>See http://pywps.wald.intevation.org and http://www.opengeospatial.org/standards/wps</ows:Abstract>
		<ows:Keywords>
			<ows:Keyword>GRASS</ows:Keyword>
			<ows:Keyword>GIS</ows:Keyword>
	<wps:ProcessOfferings>
		<wps:Process wps:processVersion="1.0">
			<ows:Identifier>returner</ows:Identifier>
			<ows:Title>Return process</ows:Title>
			<ows:Abstract>This is demonstration process of PyWPS, returns
            the same file, it gets on input, as the output.</ows:Abstract>
		</wps:Process>
	</wps:ProcessOfferings>
</wps:Capabilities>

You see, that returner process is available

DescribeProcess

/usr/local/pywps/wps.py "service=wps&version=1.0.0&request=describeprocess&identifier=returner"

We now can see process inputs definition

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
        <DataInputs>
            <Input minOccurs="1" maxOccurs="1">
                <ows:Identifier>text</ows:Identifier>
                <ows:Title>Some width</ows:Title>
                <LiteralData>
                    <ows:DataType ows:reference="http://www.w3.org/TR/xmlschema-2/#integer">integer</ows:DataType>
                    <ows:AnyValue />
                </LiteralData>
            </Input>
            <Input minOccurs="1" maxOccurs="1">
                <ows:Identifier>data</ows:Identifier>
                <ows:Title>Input vector data</ows:Title>
                <ComplexData>
                    <Default>
                        <Format>
                            <ows:MimeType>text/xml</ows:MimeType>
                        </Format>
                    </Default>
                    <Supported>
                        <Format>
                            <ows:MimeType>text/xml</ows:MimeType>
                        </Format>
                    </Supported>
                </ComplexData>
            </Input>
        </DataInputs>

as well as process outputs

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
        <ProcessOutputs>
            <Output>
                <ows:Identifier>output</ows:Identifier>
                <ows:Title>Output vector data</ows:Title>
                <ComplexOutput>
                    <Default>
                        <Format>
                            <ows:MimeType>text/xml</ows:MimeType>
                        </Format>
                    </Default>
                    <Supported>
                        <Format>
                            <ows:MimeType>text/xml</ows:MimeType>
                        </Format>
                    </Supported>
                </ComplexOutput>
            </Output>
            <Output>
                <ows:Identifier>text</ows:Identifier>
                <ows:Title>Output literal data</ows:Title>
                <LiteralOutput>
                    <ows:DataType ows:reference="http://www.w3.org/TR/xmlschema-2/#integer">integer</ows:DataType>
                </LiteralOutput>
            </Output>
        </ProcessOutputs>

Execute

Finally, let the process be executed:

/usr/local/pywps/wps.py "service=wps&version=1.0.0&request=execute&identifier=returner&datainputs=[text=1;data=http://apps.esdi-humboldt.cz/classification/traning_areas/training_areas_en.gml]"

First thing you see, is bunch of INFOs about current process status:

PyWPS INFO: Reading processes from [/home/jachym/usr/src/pywps/processes/course/]
PyWPS INFO: Following processes are imported: ['returner']
PyWPS INFO: Status [processpaused]: Getting input text of process returner
PyWPS INFO: Status [processpaused]: Getting input data of process returner
PyWPS INFO: Status [processstarted][0.0]: Process returner started
PyWPS INFO: Status [processsucceeded]: PyWPS Process returner successfully calculated

And afterwards, the resulting XML will come

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    <wps:Process wps:processVersion="1.0">
        <ows:Identifier>returner</ows:Identifier>
        <ows:Title>Return process</ows:Title>
        <ows:Abstract>This is demonstration process of PyWPS, returns
            the same file, it gets on input, as the output.</ows:Abstract>
    </wps:Process>
    <wps:Status creationTime="Wed May  5 15:46:50 2010">
        <wps:ProcessSucceeded>PyWPS Process returner successfully calculated</wps:ProcessSucceeded>
    </wps:Status>
    <wps:ProcessOutputs>
        <wps:Output>
            <ows:Identifier>text</ows:Identifier>
            <ows:Title>Output literal data</ows:Title>
            <wps:Data>
                <wps:LiteralData dataType="integer">1</wps:LiteralData>
            </wps:Data>
        </wps:Output>
        <wps:Output>
            <ows:Identifier>output</ows:Identifier>
            <ows:Title>Output vector data</ows:Title>
            <wps:Data>
                <wps:ComplexData mimeType="text/xml">
<ogr:FeatureCollection
     xmlns:ogr="http://ogr.maptools.org/"
     xmlns:gml="http://www.opengis.net/gml">
  <gml:boundedBy>
    <gml:Box>
      <gml:coord><gml:X>-559044.5280103994</gml:X><gml:Y>-1177026.734255324</gml:Y></gml:coord>
      <gml:coord><gml:X>-554835.891394174</gml:X><gml:Y>-1169621.932698363</gml:Y></gml:coord>
    </gml:Box>
  </gml:boundedBy>                        
  <gml:featureMember>
    <ogr:features fid="F0">
      <ogr:geometryProperty><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-555043.324615493183956,-1174010.838661683257669 -554930.435787564259954,-1174159.005248340079561 -555085.657925966545008,-1174293.060731505509466 -555276.157823096611537,-1174201.338558813324198 -555191.491202149889432,-1174088.449730884516612 -555043.324615493183956,-1174010.838661683257669</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>

As reference output

You can see, that the output XML response contains the resulting GML. We can request the reference to it, put this at the end of previous request string:

&responseform=responsedocument=[output=@asreference=true]

And you get

<wps:Output>
    <ows:Identifier>output</ows:Identifier>
    <ows:Title>Output vector data</ows:Title>
    <wps:Reference xlink:href="http://localhost/wps/wpsoutputs/output-9115" mimeType="text/xml"/>
</wps:Output>

You can also configure PyWPS, so the output reference URL is OGC WFS or OGC WCS, if you use mapscript in your process