WFS POST Request contains Key-Value-Pairs in URL fails

Description

I think I discovered a bug in the wfs implementation of geotools.

This method call fails with the following error:

org.geotools.data.wfs.WFSFeatureSource#getReader()

java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 400 for URL: http://server/path/wfs?REQUEST=DescribeFeatureType&VERSION=2.0.0&SERVICE=WFS

This happens only with certain WFS-Servers. We tracked down the problem to this POST-Request, that is generated from geotools:

Works not:

curl -X POST -i 'http://server/path/wfs?REQUEST=DescribeFeatureType&VERSION=2.0.0&SERVICE=WFS' --data '<?xml version="1.0" encoding="UTF-8"?><wfsescribeFeatureType xmlns:ave="http://repository.gdi-de.org/schemas/adv/produkt/alkis-vereinfacht/2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" handle="GeoTools 18.0(3f5dbf634c4a6b24476643cc7cf7d2b22747fcf5) WFS 2.0.0 DataStore @LDBV-M-W0378#1" outputFormat="application/gml+xml; version=3.2" service="WFS" version="2.0.0"><wfs:TypeName>ave:Flurstueck</wfs:TypeName></wfsescribeFeatureType>'

Works:

curl -X POST -i 'http://server/path/wfs' --data '<?xml version="1.0" encoding="UTF-8"?><wfsescribeFeatureType xmlns:ave="http://repository.gdi-de.org/schemas/adv/produkt/alkis-vereinfacht/2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" handle="GeoTools 18.0(3f5dbf634c4a6b24476643cc7cf7d2b22747fcf5) WFS 2.0.0 DataStore @LDBV-M-W0378#1" outputFormat="application/gml+xml; version=3.2" service="WFS" version="2.0.0"><wfs:TypeName>ave:Flurstueck</wfs:TypeName></wfsescribeFeatureType>'

The "works not" Request is the one produced by geotools. This happens also with the actual release of geotools. The "works" Request is a OGC conform Request.

I tracked down the class, that makes the problem. It is the class org.geotools.data.wfs.internal.WFSRequest in the unsupported module gt-wfs-ng. The problem lies in the construktor, where it says:

1 2 3 setProperty(SERVICE,"WFS"); setProperty(VERSION, strategy.getVersion()); setProperty(REQUEST, operation.getName());

This properties should only be set, if this.doPost is false, because otherwise the method getFinalURL() delivers a URL with Key-Value-Pairs, even if it is a POST-Request. And this causes this problem with certain WFS-Servers.

So this should be:

1 2 3 4 5 if (!this.doPost) { setProperty(SERVICE,"WFS"); setProperty(VERSION, strategy.getVersion()); setProperty(REQUEST, operation.getName()); }

Environment

Windows 10
WFS-Server is XtraServer

Status

Assignee

Unassigned

Reporter

Matthias Schulze

Triage

None

Components

Affects versions

21.2
22.0

Priority

Medium
Configure