52n-wps-client-lib and 52n-wps-r service

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

52n-wps-client-lib and 52n-wps-r service

Carsten.Friedrich

I’m trying to use 52n-wps-client-lib to call a R based WPS service running under 52n-wps-r.

In the R script, the output is defined as:

 

# wps.out: output, text;

 

In my Java program I define the output like so:

 

        executeBuilder.setMimeTypeForOutput("text/plain", "output");

        executeBuilder.setEncodingForOutput("UTF-8", "output");

 

This succeeds and I get the expected result back (I can see it in the result XML sent back). However, when try to retrieve it like so:

 

IData cdata = (IData) analyser.getComplexData("output", PlainStringBinding.class);

 

this results in:

 

Exception in thread "main" java.lang.RuntimeException: Could not find suitable parser

 

The problem seems to be that WPS4R returns a mime type and encoding, but no schema. WCPSQueryParser however requires the schema to be set to http://schemas.opengis.net/wcps/1.0/wcpsAll.xsd and does not accept “null”.

 

I tried adding:

 

        executeBuilder.setSchemaForOutput(

                "http://schemas.opengis.net/wcps/1.0/wcpsAll.xsd", "output");

 

To my code, but this is rejected as an unsupported schema for this output.

 

Cheers,

Carsten

 

--

Dr Carsten Friedrich

Research Team leader

CSIRO Computational Informatics

GPO Box 664,Canberra, ACT 2601

Phone: +61 2 6216 7019

Email: [hidden email]

 

 


_______________________________________________
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
|

Re: 52n-wps-client-lib and 52n-wps-r service

BenjaminPross
Hello Carsten,

At the moment, the PlainStringBinding is used only by the WCPSQueryParser and like you already found out, this parser cannot be used for the output.
To get your result, you can use The GenericFileDataBinding, i.e.:

GenericFileDataBinding data = (GenericFileDataBinding) analyser.getComplexData("output",
                                        GenericFileDataBinding.class);
                       
File f = ((GenericFileData)data.getPayload()).getBaseFile(false);


Hope this helps.

Cheers,

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: 52n-wps-client-lib and 52n-wps-r service

Carsten.Friedrich
Hi Benjamin,

Thanks, this works. I noticed however that the file contains not only the result of the R script, but a complete XML document containing a xml-fragmnent containing the result, i.e. requiring post-processing on the client side. Is this the expected behaviour?

Cheers,
Carsten

--
Dr Carsten Friedrich
Research Team leader
CSIRO Computational Informatics
GPO Box 664,Canberra, ACT 2601
Phone: +61 2 6216 7019
Email: [hidden email]




-----Original Message-----
From: Geoprocessingservices [mailto:[hidden email]] On Behalf Of BenjaminPross
Sent: Monday, 3 November 2014 20:56
To: [hidden email]
Subject: Re: [52N Geoprocessingservices] 52n-wps-client-lib and 52n-wps-r service

Hello Carsten,

At the moment, the PlainStringBinding is used only by the WCPSQueryParser and like you already found out, this parser cannot be used for the output.
To get your result, you can use The GenericFileDataBinding, i.e.:

GenericFileDataBinding data = (GenericFileDataBinding) analyser.getComplexData("output",
                                        GenericFileDataBinding.class);
                       
File f = ((GenericFileData)data.getPayload()).getBaseFile(false);


Hope this helps.

Cheers,

Benjamin



--
View this message in context: http://geoprocessing.forum.52north.org/52n-wps-client-lib-and-52n-wps-r-service-tp4025899p4025901.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
_______________________________________________
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
|

Re: 52n-wps-client-lib and 52n-wps-r service

BenjaminPross
Hello Carsten,

This is a bug in the ExecuteResponseAnalyser class of the client lib. I attached a patched version of it: ExecuteResponseAnalyser.java.  

Hope this helps.

Cheers,

Benjamin
Reply | Threaded
Open this post in threaded view
|

Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Carsten.Friedrich
In reply to this post by Carsten.Friedrich
Since 3.3.1-SNAPSHOT is no longer in the maven repository I had to move to 3.3.1 release. I currently have the following regression problem: Trying to retrieve a complex output always returns an empty string. I suspect this is related to changes in ExecuteResponseAnalyser.parseProcessOutput line 221 and following.

At this stage processOutput looks like this:

<xml-fragment xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ows:Identifier>output</ows:Identifier>
  <ows:Title>id</ows:Title>
  <wps:Data>
    <wps:ComplexData encoding="UTF-8" mimeType="text/plain">-7.40514611158735,-7.37547553525108,
0.000807631458002566,0.000976517508558758,0.00117385955759824,0.00140307904050947,0.00166780613588543,0.00198113924731385,0.00234801240651876,0.0027678130670427,0.00324558415532555,0.00378654451514649,0.00441097366568519,0.00512533523159306,0.00592557076125341,0.00681758704520043,0.00780728262587848,0.0486958694965902,0.0521034455695554,0.0555626741599691,0.0590621134262661,0.0625772603108293,0.0660869 [...]

After the next 3 steps complexDataNode has QName "mimeType" and complexDataContent is "".

--
Dr Carsten Friedrich
Research Team leader
CSIRO Computational Informatics
GPO Box 664,Canberra, ACT 2601
Phone: +61 2 6216 7019
Email: [hidden email]

 

_______________________________________________
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
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

BenjaminPross
Hello Carsten,

This is strange, with a very similar output:

<xml-fragment xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ows:Identifier>ComplexOutputData1</ows:Identifier>
  <ows:Title>ComplexOutputData1</ows:Title>
  <wps:Data>
    <wps:ComplexData mimeType="text/plain" encoding="UTF-8">-7.40514611158735,-7.37547553525108,
0.000807631458002566,0.000976517508558758,0.00117385955759824,0.00140307904050947,0.00166780613588543,0.00198113924731385,0.00234801240651876,0.0027678130670427</wps:ComplexData>
  </wps:Data>
</xml-fragment>

the complexDataContent correctly contains the output-String.
So I guess something goes wrong during the transformation of the Node to a String.
Can you call complexDataNode.getNodeValue() during debugging? If yes, what is the result?
What version of Java are you using and do you use Oracle or OpenJDK/JRE?
How big is the output-String (i.e. is it really big)? Are there maybe some special characters in the output-String?

Cheers,

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Carsten.Friedrich
I'll see if I can get complexDataNode.getNodeValue().

In the meantime:
Java Version: Oracle Jdk 1.7.0_71 64Bit Windows
Size of output string: The vector contains about 1000 double values encoded as comma separated strings.

c

--
Dr Carsten Friedrich
Research Team leader
CSIRO Computational Informatics
GPO Box 664,Canberra, ACT 2601
Phone: +61 2 6216 7019
Email: [hidden email]




-----Original Message-----
From: Geoprocessingservices [mailto:[hidden email]] On Behalf Of BenjaminPross
Sent: Thursday, 2 April 2015 20:57
To: [hidden email]
Subject: Re: [52N Geoprocessingservices] Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Hello Carsten,

This is strange, with a very similar output:

<xml-fragment xmlns:ows="http://www.opengis.net/ows/1.1"
xmlns:wps="http://www.opengis.net/wps/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ows:Identifier>ComplexOutputData1</ows:Identifier>
  <ows:Title>ComplexOutputData1</ows:Title>
  <wps:Data>
    <wps:ComplexData mimeType="text/plain"
encoding="UTF-8">-7.40514611158735,-7.37547553525108,
0.000807631458002566,0.000976517508558758,0.00117385955759824,0.00140307904050947,0.00166780613588543,0.00198113924731385,0.00234801240651876,0.0027678130670427</wps:ComplexData>
  </wps:Data>
</xml-fragment>

the complexDataContent correctly contains the output-String.
So I guess something goes wrong during the transformation of the Node to a String.
Can you call complexDataNode.getNodeValue() during debugging? If yes, what is the result?
What version of Java are you using and do you use Oracle or OpenJDK/JRE?
How big is the output-String (i.e. is it really big)? Are there maybe some special characters in the output-String?

Cheers,

Benjamin



--
View this message in context: http://geoprocessing.forum.52north.org/52n-wps-client-lib-and-52n-wps-r-service-tp4025899p4026045.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
_______________________________________________
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
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Carsten.Friedrich
In reply to this post by BenjaminPross
complexDataNode.getNodeValue() contains the content of <wps:ComplexData>, i.e. ">-7.40514611158735,-7.37547553525108,
0.000807631458002566,0.000976517508558758,0.00117385955759824,0.00140307904050947,0.00166780613588543,0.00198113924731385,0.00234801240651876,0.0027678130670427,..."

Maybe it's the Transformer in nodeToString() ?

In my instance where it fails (Tomcat webapp) the Transformer instance is of class net.sf.saxon.IdentityTransformer.

In my unit tests which don't fail, albeit with a different data set, the Transformer instance is of class org.apache.xalan.transformer.TransformerIdentityImpl.

Carsten

--
Dr Carsten Friedrich
Research Team leader
CSIRO Computational Informatics
GPO Box 664,Canberra, ACT 2601
Phone: +61 2 6216 7019
Email: [hidden email]




-----Original Message-----
From: Geoprocessingservices [mailto:[hidden email]] On Behalf Of BenjaminPross
Sent: Thursday, 2 April 2015 20:57
To: [hidden email]
Subject: Re: [52N Geoprocessingservices] Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Hello Carsten,

This is strange, with a very similar output:

<xml-fragment xmlns:ows="http://www.opengis.net/ows/1.1"
xmlns:wps="http://www.opengis.net/wps/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ows:Identifier>ComplexOutputData1</ows:Identifier>
  <ows:Title>ComplexOutputData1</ows:Title>
  <wps:Data>
    <wps:ComplexData mimeType="text/plain"
encoding="UTF-8">-7.40514611158735,-7.37547553525108,
0.000807631458002566,0.000976517508558758,0.00117385955759824,0.00140307904050947,0.00166780613588543,0.00198113924731385,0.00234801240651876,0.0027678130670427</wps:ComplexData>
  </wps:Data>
</xml-fragment>

the complexDataContent correctly contains the output-String.
So I guess something goes wrong during the transformation of the Node to a String.
Can you call complexDataNode.getNodeValue() during debugging? If yes, what is the result?
What version of Java are you using and do you use Oracle or OpenJDK/JRE?
How big is the output-String (i.e. is it really big)? Are there maybe some special characters in the output-String?

Cheers,

Benjamin



--
View this message in context: http://geoprocessing.forum.52north.org/52n-wps-client-lib-and-52n-wps-r-service-tp4025899p4026045.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
_______________________________________________
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
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

BenjaminPross
You're right, that is the problem. You can specify the transfomer factory to avoid this.
In the XMLUtil class (52n-wps-commons module), change line 139 to:

        Transformer transformer = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null).newTransformer();

If that is not possible for you, let us know. We can think of a different approach, then.

Cheers,

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Daniel
Am 09/04/2015 um 16:34 schrieb BenjaminPross:
> You're right, that is the problem. You can specify the transfomer factory to
> avoid this.
> In the XMLUtil class (52n-wps-commons module), change line 139 to:
>
>          Transformer transformer =
> TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl",
> null).newTransformer();

Imho it might be useful to make this parameter configurable. What do you
guys think?

@Benjamin: This could be part of the new configuration mechanism, I
wouldn't bother to add this to the XML file. Should I open a new issue
to note this down?

/Daniel

> If that is not possible for you, let us know. We can think of a different
> approach, then.
>
> Cheers,
>
> Benjamin
>
>
>
> --
> View this message in context: http://geoprocessing.forum.52north.org/52n-wps-client-lib-and-52n-wps-r-service-tp4025899p4026048.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
Reply | Threaded
Open this post in threaded view
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Carsten.Friedrich
In reply to this post by BenjaminPross
Hi Benjamin,

Thanks for that. I can change it on my development machine, but it's hard for me to propagate that to our build/test/deploy environment. I'd basically have to fork your work and upload my changes to some maven repository (or the changed source to git) to make them accessible. I'd rather not do that.

Carsten

--
Dr Carsten Friedrich
Research Team leader
CSIRO Computational Informatics
GPO Box 664,Canberra, ACT 2601
Phone: +61 2 6216 7019
Email: [hidden email]



-----Original Message-----
From: Geoprocessingservices [mailto:[hidden email]] On Behalf Of BenjaminPross
Sent: Friday, 10 April 2015 00:34
To: [hidden email]
Subject: Re: [52N Geoprocessingservices] Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

You're right, that is the problem. You can specify the transfomer factory to avoid this.
In the XMLUtil class (52n-wps-commons module), change line 139 to:

        Transformer transformer =
TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl",
null).newTransformer();

If that is not possible for you, let us know. We can think of a different approach, then.

Cheers,

Benjamin



--
View this message in context: http://geoprocessing.forum.52north.org/52n-wps-client-lib-and-52n-wps-r-service-tp4025899p4026048.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
_______________________________________________
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
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

BenjaminPross
Hi Carsten,

Another option would be to add the following statement to your client code:

System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");

Hope this helps.

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Carsten.Friedrich
Hi Benjamin,

This (or some equivalent of it) would probably work, but seems very heavy handed given that my code is only a library - ie I probably shouldn't force this setting globally on an application that uses it.

Since wps-client seems to rely on using exactly this TransformerFactory I think it would be more appropriate to change
XMLUtil class in the official repository to:

        Transformer transformer = TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl", null).newTransformer();

This would also prevent others from running into the same problem.

Cheers,
Carsten

--
Dr Carsten Friedrich
Research Team leader
CSIRO Computational Informatics
GPO Box 664,Canberra, ACT 2601
Phone: +61 2 6216 7019
Email: [hidden email]




-----Original Message-----
From: Geoprocessingservices [mailto:[hidden email]] On Behalf Of BenjaminPross
Sent: Wednesday, 29 April 2015 19:27
To: [hidden email]
Subject: Re: [52N Geoprocessingservices] Regression problem moving from wps-client 3.3.1-SNAPSHOT to 3.3.1 release

Hi Carsten,

Another option would be to add the following statement to your client code:

System.setProperty("javax.xml.transform.TransformerFactory",
"org.apache.xalan.processor.TransformerFactoryImpl");

Hope this helps.

Benjamin



--
View this message in context: http://geoprocessing.forum.52north.org/52n-wps-client-lib-and-52n-wps-r-service-tp4025899p4026066.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
_______________________________________________
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