How to obtain information about the feature WFS layer in different versions of WFS 1.0.0 / 1.1.0 / 2.0.0 ?

The OL documentation says

Feature format for reading and writing data in the WFS format. By default, supports WFS version 1.1.0. You can pass a GML format as option if you want to read a WFS that contains GML2 (WFS 1.0.0). Also see ol.format.GMLBase which is used by this format.

Ok, example WFS - GetFeature is performed in the version 1.1.0

var f = ol.format.ogc.filter;
var wfs = new ol.format.WFS();
    srsName: 'EPSG:3857',
    featureNS: 'http://openstreemap.org',
    featurePrefix: 'osm',
    featureTypes: ['water_areas'],
    outputFormat: 'application/json',
    filter: f.and(
        f.like('name', 'Mississippi*'),
        f.equalTo('waterway', 'riverbank')

But it always forms a request in WFS version 1.1.0.
How to form GetFeature request in WFS versions 2.0.0 using writeGetFeature function?


2 Answers 2


I may be a bit late, but as I myself was looking for how to change the version in writeGetFeature to 2.0.0 in the current version of OL (v7.2.2) maybe someone else will find this answer useful.
It turns out that specifying the version in the WFS constructor allows writeGetFeature to be written in the desired form:

import { WFS } from 'ol/format.js';
import {
    and as andFilter,
    like as likeFilter,
    equalTo as equalToFilter,
} from 'ol/format/filter.js';

const featureRequest = new WFS({ version: '2.0.0' })
        srsName: 'EPSG:3857',
        featureNS: 'http://openstreemap.org',
        featurePrefix: 'osm',
        featureTypes: [ 'water_areas' ],
        outputFormat: 'application/json',
        filter: andFilter(
            likeFilter('name', 'Mississippi*'),
            equalToFilter('waterway', 'riverbank'),

console.log(new XMLSerializer().serializeToString(featureRequest));

results with:

    service="WFS" version="2.0.0" outputFormat="application/json"
    xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd"
  <Query typeNames="osm:water_areas" srsName="EPSG:3857" xmlns:osm="http://openstreemap.org">
    <Filter xmlns="http://www.opengis.net/fes/2.0">
        <PropertyIsLike wildCard="*" singleChar="." escapeChar="!">

A question on the OL3 developers forum, from June 2014, tells us that whilst there is support for WFS 2 in OL 2, there is no such support for WFS 2 in OL3!

WFS / GML versioning support

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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