I am following this example from OpenLayers' examples page so I can load a WFS layer pulled from MapServer. I copy and paste the code and the only thing I change is the EPSG in the function as the following snippet:

var vectorSource = new ol.source.Vector({
    format: new ol.format.GeoJSON(),
    url: function(my_extent) {
      return 'http://localhost/cgi-bin/mapserv?map=/home/user/mapdata/mapFile.map&service=WFS&' +
          'version=1.1.0&request=GetFeature&typename=Rivers&' +
          'outputFormat=application/json&srsname=EPSG:2100&' +
          'bbox=' + my_extent.join(',') + ',EPSG:2100';
    strategy: ol.loadingstrategy.bbox

  var vector = new ol.layer.Vector({
    source: vectorSource,
    style: new ol.style.Style({
      stroke: new ol.style.Stroke({
        color: 'rgba(0, 0, 255, 1.0)',
        width: 2

When I load it on the browser I get a white page and by opening the Network tab I click on my WFS link and a new page opens giving me the following error:

msWFSGetFeature(): WFS server error. 'application/json' is not a permitted output format for layer 'Rivers', review wfs_getfeature_formatlist setting.

I presume it is most likely a MapServer associated error but can somebody point me towards a solution?


I presume it is most likely a MapServer associated error

The error isn't a MapServer error, the error is that you have requested an outputFormat that is not supported by the MapServer WFS service.

You can check which formats are supported for a GetFeature request by doing a GetCapabilities request, which for a standard MapServer WFS (using defaults) are:

<ows:Operation name="GetFeature">
            <ows:Get xlink:type="simple" xlink:href="http://your-service/cgi-bin/blah-blah/wms?"/>
            <ows:Post xlink:type="simple" xlink:href="http://your-service/cgi-bin/blah-blah/wms?"/>
    <ows:Parameter name="outputFormat">
            <ows:Value>application/gml+xml; version=3.2</ows:Value>
            <ows:Value>text/xml; subtype=gml/3.2.1</ows:Value>
            <ows:Value>text/xml; subtype=gml/3.1.1</ows:Value>
            <ows:Value>text/xml; subtype=gml/2.1.2</ows:Value>

As application/json is not listed here, it would be an error for you to request such an outputFormat.

If it is your MapServer service you can add to the default formats. The MapServer documentation explains how you can do this: http://mapserver.org/uk/output/ogr_output.html#ogr-output

  • Thank you. I had to add this to my mapfile OUTPUTFORMAT NAME "geojson" DRIVER "OGR/GEOJSON" MIMETYPE "application/json; subtype=geojson" FORMATOPTION "STORAGE=stream" FORMATOPTION "FORM=SIMPLE" END My Openlayers snippet I've wrote above gives me only the ability to request on feature at a time. Meaning typename=Roads,Rivers won't display the layers and pop an error about my projection. Why ? – Stefanos Feb 8 '17 at 14:22
  • 1
    You're probably straying into a new question for projection issues. First does the service report that it supports the coordinate reference system that you are requesting? Have you tried requesting the coordinate reference system using the form advised in the GetCapabilities response like srsname=urn:ogc:def:crs:EPSG::2100 perhaps? Do you get a different behaviour between the GeoJSON and the GML response? – nmtoken Feb 8 '17 at 15:10

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.