I want to retrieve the feature Collection from a WFS server with the Java library GeoTools. I tried this code, but unfortunately the program fails to execute.

public class App {
public static void main( String[] args ) throws IOException{
    String getCapabilities = "http://localhost:8081/geoserver/wfs?REQUEST=GetCapabilities&version=1.0.0";

    Map connectionParameters = new HashMap();
    connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", getCapabilities );
    WFSDataStoreFactory  dsf = new WFSDataStoreFactory();
    try {
        WFSDataStore dataStore = dsf.createDataStore(connectionParameters);
        SimpleFeatureSource source = dataStore.getFeatureSource("Gruen:Gruenflaechen");
        SimpleFeatureCollection fc = source.getFeatures();

        while(fc.features().hasNext()){             //line 33
            SimpleFeature sf = fc.features().next();

    } catch (IOException ex) {

By running this code, I get an IllegalArgumentException at line 33.

Exception in thread "main" java.lang.IllegalArgumentException: Server does not support 'text/xml; subtype=gml/3.1.1' output format: [text/xml; subType=gml/3.1.1/profiles/gmlsf/1.0.0/0]

The output also says that it can't decode CRS EPSG:25832 for Gruen:Gruenflaechen and that I would create a location and a shape with null CoordinateReferenceSystem

I have no idea how to solve this problem and as you might have noticed I am not really a GIS expert. All I want to do is to receive the Geodata from the WFS and save it into an own Java Object. Would be very grateful for help!


Okay, I found the solution. I just had to add a connectionParameter:

connectionParameters.put("WFSDataStoreFactory:OUTPUTFORMAT", "text/xml; subType=gml/3.1.1/profiles/gmlsf/1.0.0/0");

closed as off-topic by Ian Turton Jun 11 '18 at 9:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – Ian Turton
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Your solution should be posted below as the "Answer", so you can close this off. It might seem a bit strange, but think "Q&A site", rather than "forum site". – BradHards Nov 7 '14 at 9:41