Creating an OGC Web Feature Service
Using MapServer and PostGIS

Testing your WFS Server

As with the WMS you set up earlier, a simple web browser can be used for sending HTTP Requests to the WFS. A WFS according to the OGC specification supports at least these three requests: GetCapabilities, DescribeFeatureType and GetFeature.

First we use the GetCapabilities Request to find out if what the service supports. Type the following request URL in a web browser:

https://gisedu.itc.utwente.nl/cgi-bin/mapserv.exe?map=[NETPATH]/configWFS.map&SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities

Next, the DescribeFeatureType Request is used to generate an XML document describing more details on one or more feature types (layers). Type the following request URL in a web browser:

https://gisedu.itc.utwente.nl/cgi-bin/mapserv.exe?map=[NETPATH]/configWFS.map&SERVICE=WFS&VERSION=2.0.0&REQUEST=DescribeFeatureType&TYPENAME=airportsWFS&OUTPUTFORMAT=text/xml; subtype=gml/2.1.2

The information about our WFS returned by this document is all attributes of the layer 'AirportsWFS'. If you do not include the TYPENAME= parameter, you get information on all available layers in the WFS service.
We include the parameter OUTPUTFORMAT=text/xml; subtype=gml/2.1.2 here, because if you leave this out, the default output requested is GML3, which can not be shown in most browsers (it will ask you to download as a file instead)

Finally, we use the GetFeature Request to request from the Web Feature Service actual instances of one or more feature types. Type the following request URL in a web browser:

https://gisedu.itc.utwente.nl/cgi-bin/mapserv.exe?map=[NETPATH]/configWFS.map&SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAME=airportsWFS&MAXFEATURES=5&OUTPUTFORMAT=text/xml; subtype=gml/2.1.2

The result should be a GML file send to your browser. You can either read it in the browser or save the file and use an XML editor to show it. The most used GetFeature Request parameters are:

  • TYPENAME specifies the (comma-delimited list of) name(s) of the feature type(s) to be requested;
  • MAXFEATURES sets the maximum number of features to be returned (if not included, you retrieve all data in the layer). This is useful for first testing if the WFS works, with a small selection;
  • BBOX sets the extents of the data you request. If not used, you get all the data in the default extent as set in the WFS configuration (in our case, in the MAP file).

Consuming the WFS in GIS

Of course, consuming the WFS output in a web browser is not very user-friendly, nor is it actually all that useful to receive the data as text in your browser. But you can use any open standard WFS-compliant client, for example QGIS or ArcMAP, to use this WFS as a source of data. You can check out the description of how this works in the previous WMS exercise.

Open the airportsWFS layer in QGIS, ArcMAP or another WFS capable GIS-client, and try to change the symbolization of the layer, with labels depicting the airport name...