3

I am trying to access a WFS using geotools. Access is working with version 1.0.0 and 1.1.0 without problems. Here my code:

// Conenction
String getCapabilities = WFSDataStoreFactory.createGetCapabilitiesRequest(new URL("http://demo.opengeo.org/geoserver/wfs"), new Version("2.0.0")).toString();
Map connectionParameters = new HashMap();
connectionParameters.put(WFSDataStoreFactory.URL.key, getCapabilities);
WFSDataStoreFactory dsf = new WFSDataStoreFactory();
WFSDataStore dataStore = dsf.createDataStore(connectionParameters);
// Layer
SimpleFeatureSource source = dataStore.getFeatureSource("maps:ne_10m_lakes");
// Features
SimpleFeatureCollection fc = source.getFeatures();
SimpleFeatureIterator iterator = fc.features();
while (iterator.hasNext()) {
    SimpleFeature sf = iterator.next();
    // dostuff
}

Using version 2.0.0 results in:

Can't find a response parser factory for DESCRIBE_FEATURETYPE/'application/xml' Failed to execute request http://demo.opengeo.org:80/geoserver/wfs?REQUEST=DescribeFeatureType&VERSION=2.0.0&SERVICE=WFS Exception in thread "main" org.geotools.factory.FactoryNotFoundException: Can't find a response parser factory for DESCRIBE_FEATURETYPE/'application/xml' at org.geotools.data.wfs.internal.WFSExtensions.findResponseFactory(WFSExtensions.java:106) at org.geotools.data.wfs.internal.WFSRequest.createResponse(WFSRequest.java:205) at org.geotools.data.wfs.internal.WFSRequest.createResponse(WFSRequest.java:38) at org.geotools.data.ows.AbstractOpenWebService.internalIssueRequest(AbstractOpenWebService.java:445) at org.geotools.data.wfs.internal.WFSClient.internalIssueRequest(WFSClient.java:292) at org.geotools.data.wfs.internal.WFSClient.issueRequest(WFSClient.java:354) at org.geotools.data.wfs.WFSDataStore.getRemoteFeatureType(WFSDataStore.java:210) at org.geotools.data.wfs.WFSDataStore.getRemoteSimpleFeatureType(WFSDataStore.java:264) at org.geotools.data.wfs.WFSFeatureSource.buildFeatureType(WFSFeatureSource.java:348) at org.geotools.data.store.ContentFeatureSource.getAbsoluteSchema(ContentFeatureSource.java:356) at org.geotools.data.store.ContentFeatureSource.getSchema(ContentFeatureSource.java:325) at org.geotools.data.store.ContentFeatureCollection.(ContentFeatureCollection.java:80) at org.geotools.data.store.ContentFeatureSource.getFeatures(ContentFeatureSource.java:583) at org.geotools.data.store.ContentFeatureSource.getFeatures(ContentFeatureSource.java:114) at TestWFS.main(TestWFS.java:79)

Any suggestions?

2

The WFS-ng plugin only supports 1.0 & 1.1.0 as mentioned in the documentation.

1

This particular WFS server is currently down at the moment (503 Not Available) so I can't test it.

But contrary to what the documentation (does not) says, GeoTools does provide support for WFS 2.0.0: see the code available at https://github.com/geotools/geotools/tree/master/modules/unsupported/wfs-ng/src/main/java/org/geotools/data/wfs/internal/v2_0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.