[GIS] Creating simple WPS client

pythonwpswpsclient

It looks like the only way to get flat files/data from a WPS service is to use a client. I'm looking to create a super-simple WPS client in Python 2.6 (or other language) without any dependencies on non-default modules.

Right now I'm gathering resources – I haven't done a lick of coding yet.

Can I use a POST HTTP request with a proper header to request a WPS file?

Additional Info:

Best Answer

I have done this using urllib2 in python.

Some simple code is

import urllib2

request_file = open("my_wps_request.xml", "r")
xml_data = request_file.read()
r = urllib2.Request(
    "http://192.168.109.147:8080/geoserver/wps",
    data=xml_data,
    headers={
        'Content-Type': 'application/xml',
        'Accept' : 'image/tiff'
        })

u = urllib2.urlopen(r)

tiff_file = open('out.tif', 'wb')
tiff_file.write(u.read())
tiff_file.close()

I am using geoserver (with python wps extension).

Geoserver Admin page has a Demos -> WPS Request Builder page. Here you can select a WPS and "Generate XML from process inputs/outputs".

Save the xml into a file (my_wps_request.xml above).

urllib2.request does a POST request with the xml data. In the above example the returned data is a tif so I just write that to a file.

Even simpler I have used curl

curl -u admin:geoserver -H "Content-Type:text/xml" -X POST -d @my_wps_request.xml http://192.168.109.147:8080/geoserver/wps > out.tiff