The Web Feature Service (WFS) interface is a standard protocol published by the Open Geospatial Consortium (OGC) for serving vector geographic data. Unlike WMS, which returns images, WFS returns the actual geographic features (points, lines, polygons) with their attributes, allowing clients to render, analyze, and edit data directly.

Note: GeoServer supports WFS 1.0.0, 1.1.0, and 2.0.0. WFS 2.0.0 is recommended for new integrations as it offers improved coordinate reference system handling and transaction support.

Service Capabilities

WFS provides three primary operations defined by the OGC specification:

Operation Description HTTP Method
GetCapabilities Returns an XML document describing the service, supported versions, available feature types, and output formats. GET
DescribeFeatureType Returns the schema (XSD) for one or more feature types, defining the structure and attribute types. GET
GetFeature Retrieves the actual feature instances. Supports filtering, sorting, and pagination. GET / POST

GetCapabilities Example

To query the capabilities of the WFS service, use the following endpoint structure:

GET Request
http://your-server/geoserver/wfs?
  service=WFS
  &version=2.0.0
  &request=GetCapabilities

GetFeature Request

The GetFeature operation is the workhorse of WFS, allowing clients to retrieve subsets of data based on spatial and attribute filters.

Simple Feature Retrieval

The most basic request retrieves all features for a specified layer:

HTTP GET
http://your-server/geoserver/wfs?
  service=WFS
  &version=2.0.0
  &request=GetFeature
  &typeName=topp:states

Filtering Features

You can filter results using CQL (Common Query Language) or full OGC Filter XML. GeoServer supports CQL via the viewparams or direct CQL filter parameter.

CQL Filter Example
http://your-server/geoserver/wfs?
  service=WFS
  &version=2.0.0
  &request=GetFeature
  &typeName=topp:states
  &cql_filter=STATE_ABBR='CA'

Request Parameters

Below is a summary of common parameters used in WFS requests.

Parameter Description Example
service Specifies the OGC service name. WFS
version The WFS specification version. 1.1.0, 2.0.0
request The operation to perform. GetFeature
typeName Workspace:Layer name of the features. geonode:rivers
outputFormat Format of the response body. application/json, application/gml+xml
sortBy Attribute to sort results by. NAME_A:desc
maxFeatures Maximum number of features to return. 100
bbox Spatial bounding box filter (minx,miny,maxx,maxy). WFS 2.0 uses WKT. [-130,30,-70,50]

Transactions (WFS-T)

WFS-T (Web Feature Service - Transactions) extends the standard WFS specification to allow clients to Insert, Update, and Delete features directly on the server. This requires the layer to have write access enabled in GeoServer.

Security Warning: Enable WFS-T carefully. Ensure proper authentication and authorization roles are configured to prevent unauthorized data modification.

Transactions are performed using the POST method with an XML body containing the transaction details.

POST Body (XML)
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/2.0/wfs.xsd">
  <wfs:Insert>
    <topp:states xmlns:topp="http://www.openplans.org/topp">
      <topp:STATE_ABBR>NX</topp:STATE_ABBR>
      <topp:NAME>New State</topp:NAME>
      <topp:the_geom xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
        <gml:Polygon>
          <gml:outerBoundaryIs>
            <gml:LinearRing>
              <gml:coordinates>-120,40 -110,40 -110,50 -120,50 -120,40</gml:coordinates>
            </gml:LinearRing>
          </gml:outerBoundaryIs>
        </gml:Polygon>
      </topp:the_geom>
    </topp:states>
  </wfs:Insert>
</wfs:Transaction>

Output Formats

GeoServer supports various output formats for WFS responses, depending on the plugins installed:

Requesting GeoJSON

Header
Accept: application/json

Or via parameter in WFS 2.0.0:

Query Param
&outputFormat=application/json

Security & Authentication

GeoServer integrates with WFS to enforce security constraints. By default, public layers may be readable, but write operations require authentication.

When accessing secured layers, include credentials in the request headers:

cURL Example
curl -X GET \
  'http://your-server/geoserver/wfs?service=WFS&request=GetFeature&typeName=topp:states' \
  -H 'Accept: application/json' \
  -u admin:geoserver

See Also