Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

WPS Client : Complex Data as non XML String #254

Open
Gnatit opened this issue Aug 14, 2017 · 0 comments
Open

WPS Client : Complex Data as non XML String #254

Gnatit opened this issue Aug 14, 2017 · 0 comments
Assignees

Comments

@Gnatit
Copy link

Gnatit commented Aug 14, 2017

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 :

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

@bpross-52n bpross-52n self-assigned this Aug 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants