WPS4R - how to pass XML file reference as input

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

WPS4R - how to pass XML file reference as input

Jiri Kadlec
I am trying to write an R-script that accepts an online XML document as input and does some processing with this XML data. Here is how I format my query:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wps:Execute service="WPS" version="1.0.0"
  xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
  xmlns:xlink="http://www.w3.org/1999/xlink" 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/wpsExecute_request.xsd">
  <ows:Identifier>org.n52.wps.server.r.ts-converter3</ows:Identifier>
  <wps:DataInputs>
    <wps:Input>
      <ows:Identifier>url</ows:Identifier>
      <wps:Reference xlink:href="http://hydrodata.info/chmi-h/cuahsi_1_1.asmx/GetValuesObject?location=CHMI-H:140&amp;variable=CHMI-H:TEPLOTA&amp;startDate=2015-06-01&amp;endDate=2015-08-03&amp;authToken=" mimeType="application/xml">
      </wps:Reference>
    </wps:Input>
    </wps:DataInputs>
  <wps:ResponseForm>
    <wps:ResponseDocument storeExecuteResponse="false">
      <wps:Output asReference="false">
        <ows:Identifier>output</ows:Identifier>
      </wps:Output>
      <wps:Output>
        <ows:Identifier>sessionInfo</ows:Identifier>
      </wps:Output>
      <wps:Output>
        <ows:Identifier>warnings</ows:Identifier>
      </wps:Output>
    </wps:ResponseDocument>
  </wps:ResponseForm>
</wps:Execute>

Here is the code of my testing R-script:
# wps.des: ts-converter3, title = Read and parse and convert WaterML time series data, 
# abstract = Convert time series to new time frame3; 
# wps.in: url, type = application/xml, title = url of timeseries,
# abstract = Points for IDW, minOccurs = 0, maxOccurs=1;
# wps.out: output, text;
library(XML)

#wps.off;
url <- 'http://hydrodata.info/chmi-h/cuahsi_1_1.asmx/GetValuesObject?location=CHMI-H:140&variable=CHMI-H:TEPLOTA&startDate=2015-07-01&endDate=2015-07-10&authToken='
#wps.on;

doc = xmlTreeParse(url)
root = xmlRoot(doc)
qry = root[["queryInfo"]]
lst = unlist(xmlToList(qry)[[2]])

output <- "Values"
write.table(lst,output)

However I get the following exception when I try to upload the script:
org.n52.wps.server.r.syntax.RAnnotationException: Invalid datatype key for R script annotations: application/xml

I also tried to set the data type as text/xml but then I get an error when executing the process:
Error. No applicable parser found for schema="null", mimeType="text/xml", encoding="UTF-8"

What is the recommended way to pass a hyperlink (reference) to a XML data document to my R script that runs behind 52North WPS?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WPS4R - how to pass XML file reference as input

Daniel
Am 04/08/2015 um 04:08 schrieb Jiri Kadlec:

> I am trying to write an R-script that accepts an online XML document as input
> and does some processing with this XML data. Here is how I format my query:
>
>
> Here is the code of my testing R-script:
>
>
> However I get the following exception when I try to upload the script:
>
>
> I also tried to set the data type as text/xml but then I get an error when
> executing the process:
>
>
> What is the recommended way to pass a hyperlink (reference) to a XML data
> document to my R script that runs behind 52North WPS?

I have never done that before, actually, using wps:Reference.

My suggestion would be to use a literal input for the URL and then
download the file in R.

Please also create an issue on GitHub with your suggestion how to
support wps:Reference - it locks like a good idea to support this. The
input type should probably be "url" or something like that.

Also important: Which version of the WPS are you using?

/Daniel

--
Daniel Nüst
52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
48155 Münster, Germany
E-Mail: [hidden email]
Fon: +49-(0)-251–396371-36
Fax: +49-(0)-251–396371-11

http://52north.org/
Twitter: @FiveTwoN

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849
_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org
Please respect our mailing list guidelines:
http://52north.org/resources/mailing-lists-and-forums/guidelines
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WPS4R - how to pass XML file reference as input

Jiri Kadlec
I am using 52North WPS version 3.3.1.
I also tried passing the url parameter as wps:LiteralData but that gives me the following error:

Assignments operators found, not allowed, illegal input 'http://hydrodata.info/chmi-h/cuahsi_1_1.asmx/GetValuesObject?location=CHMI-H:140&variable=CHMI-H:TEPLOTA&startDate=2015-06-01&endDate=2015-08-03&authToken=

It looks like the WPS has a problem when there are "=" characters in the URL parameter value.
As a temporary workaround, I have replaced the "=" character by the "!" character before passing the URL to the WPS, and in the R-script I change again "!" to "=" to get the correct URL and pull the data from it.

Any suggestion for a better workaround?

I'm also going to create a related issue on Github.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: WPS4R - how to pass XML file reference as input

Daniel
Am 04/08/2015 um 17:39 schrieb Jiri Kadlec:

> I am using 52North WPS version 3.3.1.
> I also tried passing the url parameter as wps:LiteralData but that gives me
> the following error:
>
> Assignments operators found, not allowed, illegal input
> 'http://hydrodata.info/chmi-h/cuahsi_1_1.asmx/GetValuesObject?location=CHMI-H:140&variable=CHMI-H:TEPLOTA&startDate=2015-06-01&endDate=2015-08-03&authToken=
>
> It looks like the WPS has a problem when there are "=" characters in the URL
> parameter value.
> As a temporary workaround, I have replaced the "=" character by the "!"
> character before passing the URL to the WPS, and in the R-script I change
> again "!" to "=" to get the correct URL and pull the data from it.
>
> Any suggestion for a better workaround?

Ah, I see - that is a bug in the rather crude security mechanism, any
"risky" characters are not allowed in literal input as they might be
executed in the R session. Not impossible to circumvent, but I thought
at some point it is worth to take that option away.

So no other workaround suggested. The best solution in your case would
indeed be implementing support for WPS reference in WPS4R.

> I'm also going to create a related issue on Github.

https://github.com/52North/WPS/issues/184

Any other issues with your process?


/Daniel


>
>
>
> --
> View this message in context: http://geoprocessing.forum.52north.org/WPS4R-how-to-pass-XML-file-reference-as-input-tp4026117p4026119.html
> Sent from the 52° North - Geoprocessing Community Forum mailing list archive at Nabble.com.
> _______________________________________________
> Geoprocessingservices mailing list
> [hidden email]
> http://list.52north.org/mailman/listinfo/geoprocessingservices
> http://geoprocessing.forum.52north.org
> Please respect our mailing list guidelines:
> http://52north.org/resources/mailing-lists-and-forums/guidelines
>


--
Daniel Nüst
52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
48155 Münster, Germany
E-Mail: [hidden email]
Fon: +49-(0)-251–396371-36
Fax: +49-(0)-251–396371-11

http://52north.org/
Twitter: @FiveTwoN

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849
_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org
Please respect our mailing list guidelines:
http://52north.org/resources/mailing-lists-and-forums/guidelines
Loading...