When using the WPS Client API, I have a problem using the method addComplexData of class ExecuteRequestBuilder (the one using an IData object as value). In case the generator used returns a stream that is no XML, the method setComplexData will fail to read the stream.
Here is an example :
Geometry geometry = geometryFactory.createPoint(new Coordinate(0, 0));
IData data = new JTSGeometryBinding(geometry);
executeBuilder.addComplexData("start", data, null, null, "application/wkt");
The JTSGeometryBinding is used with WKTGenerator to generate a WKT description of the geometry (i.e. POINT(0 0)). This non XML String is not parsed by method setComplexData. So an empty input is generated.
Error is due to this code :
try {
data.set(XmlObject.Factory.parse(stream));
} catch (XmlException e) {
LOGGER.warn("error parsing data stream as xml node, trying to parse data as xs:string");
String text = "";
int i = -1;
try {
while ((i = stream.read()) != -1) {
text = text + (char) i;
}
} catch (IOException e1) {
LOGGER.error("error parsing stream", e);
}
The stream is read twice but the position is not reseted so the second time, stream is empty. A solution would be to convert stream to a String before parsing.
If this is not clear, I can provide additional infos. Thanks for your work
Hello,
When using the WPS Client API, I have a problem using the method addComplexData of class ExecuteRequestBuilder (the one using an IData object as value). In case the generator used returns a stream that is no XML, the method setComplexData will fail to read the stream.
Here is an example :
The JTSGeometryBinding is used with WKTGenerator to generate a WKT description of the geometry (i.e.
POINT(0 0)
). This non XML String is not parsed by method setComplexData. So an empty input is generated.Error is due to this code :
The stream is read twice but the position is not reseted so the second time, stream is empty. A solution would be to convert stream to a String before parsing.
If this is not clear, I can provide additional infos. Thanks for your work