[Pywps-dev] pywps - json output

Jachym Cepicky jachym.cepicky at gmail.com
Sun Oct 23 12:33:31 PDT 2016


You are assuming, WPS is json-based format. But it's not. There are some
rather proprietary solutions around, but WPS is XML-based communication
protocol and PyWPS currently supports only XML in and output.

You can propose how we could implement JSON by pull request

if you want to interact with JSON, have a look at JSONIX [1], which should
have support for WPS too

J

[1] https://github.com/highsource/jsonix

ne 23. 10. 2016 v 19:17 odesílatel Sylvain Beorchia <
sylvain.beorchia at gmail.com> napsal:

> Thank you for the fix Jachym.
>
> But apparently it just changes the output, from :
>
> ...
> <wps:ComplexData mimeType="application/geojson">
> <![CDATA[
>
> WwogICJmb28iLCAKICB7CiAgICAiYmFyIjogWwogICAgICAiYmF6IiwgCiAgICAgIG51bGwsIAogICAgICAxLjAsIAogICAgICAyCiAgICBdCiAgfQpd
> ]]>
> </wps:ComplexData>
>
> to:
>
> <wps:ComplexData mimeType="application/geojson">
> [ "foo", { "bar": [ "baz", null, 1.0, 2 ] } ]
> </wps:ComplexData>
>
>
> JSON, but still in XML result.
> Am i doing something wrong in my code ?
>
>
> Thanks .
>
> Sylvain.
>
>
> 2016-10-23 8:01 GMT+02:00 Jachym Cepicky <jachym.cepicky at gmail.com>:
>
> Hi Sylvain,
>
> fixed in master https://github.com/geopython/pywps/pull/201
>
> Hope, it works
>
> J
>
>
>
> so 22. 10. 2016 v 23:42 odesílatel Sylvain Beorchia <
> sylvain.beorchia at gmail.com> napsal:
>
> Hi all,
>
> Trying to build my first WPS, i want to return JSON outputs. After many
> tests, i always got some JSON encoded chars embeded in XML, or clear JSON
> embeded in XML...always XML.
> Here is the simple code i've tried :
>
>
> import json
> from pywps import Process, LiteralInput, LiteralOutput, OGCUNIT, UOM,
> ComplexInput, ComplexOutput, Format, FORMATS
>
> class Test(Process):
>     def __init__(self):
>         inputs = [LiteralInput('name', 'Input name', data_type='string')]
>         outputs = [ComplexOutput('out', 'Referenced Output',
> supported_formats=[Format('application/geojson')])]
>
>         super(Test, self).__init__(
>             self._handler,
>             identifier='cartogsm',
>             title='Process Test',
>             version='1.0.0.0',
>             inputs=inputs,
>             outputs=outputs,
>             store_supported=True,
>             status_supported=True
>         )
>
>     def _handler(self, request, response):
>         data = json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
>         out_bytes = json.dumps(data, indent=2)
>         response.outputs['out'].output_format = 'application/json'
>         response.outputs['out'].data = out_bytes
>
>         return response
>
>
> Ouput :
> ...
> <wps:ProcessOutputs>
> <wps:Output>
> <ows:Identifier>out</ows:Identifier>
> <ows:Title>Referenced Output</ows:Title>
> <wps:Data>
> <wps:ComplexData mimeType="application/geojson">
> <![CDATA[
>
> WwogICJmb28iLCAKICB7CiAgICAiYmFyIjogWwogICAgICAiYmF6IiwgCiAgICAgIG51bGwsIAogICAgICAxLjAsIAogICAgICAyCiAgICBdCiAgfQpd
> ]]>
> </wps:ComplexData>
> </wps:Data>
> </wps:Output>
> </wps:ProcessOutputs>
> </wps:ExecuteResponse>
>
>
> How can i return only JSON, with no XML at all ?
>
> Thank you.
> _______________________________________________
> pywps-dev mailing list
> pywps-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pywps-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pywps-dev/attachments/20161023/de00e66d/attachment.html>


More information about the pywps-dev mailing list