1

I am trying to retrieve Map content via WFS Geoserver connection in Java with Geotools 18.4. But I am getting the following error: Content type is required for org.geotools.data.ows.Response.

The idea is that i want to map features (Position and Heartrate of a running person) of a WFS Layer with the java processing library.

I would be very grateful if someone can help me with this error.

here is the code:

`

import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.geotools.data.DataStore;
import org.geotools.data.wfs.WFSDataStoreFactory;

public class Heartrate2 {

  public static void main(String[] args) throws IOException {
    Heartrate2 me = new Heartrate2();
    DataStore ds = me.dataStoreWFS();
    for (String n:ds.getTypeNames()) {
      System.out.println(n);
    }
  }

public DataStore dataStoreWFS() {
    DataStore dataStore = null;

    try {
        Map<String, Serializable> connectionParameters = new HashMap<>();
        String getCapabilities = "http://webgis.regione.sardegna.it/geoserver/ows?service=WFS&request=GetCapabilities";
        String variableCapabilities = "WFSDataStoreFactory:GET_CAPABILITIES_URL";

        connectionParameters.put(variableCapabilities, getCapabilities);

        dataStore = (new WFSDataStoreFactory()).createDataStore(connectionParameters);
        } catch (IOException e) {
            e.printStackTrace();
            }
    return dataStore;
    }
}

`

Chris S.
  • 21
  • 2

0 Answers0