GetFeature

The Web Feature Service (WFS) is able to service a request to retrieve feature instances. In addition, the client is able to specify which feature properties to fetch and is able to constrain the query spatially and non-spatially. The service can return the search results of a feature (content) based on the description returned in the DescribeFeatureType request.

An application applies filters to retrieve a specific set of features that satisfy the condition specified by the filter. For example, to get the various attributes, geographic or otherwise. Filters also let customers select a set of features for analysis, such as all the water features within a region or a new housing development (a custom polygon).

The GetFeature operation retrieves features and specified information about the feature from the WFS server. An XML document that contains the result set is returned to the client.

POST Request

The XML encoding of a GetFeature request is defined by the XML Schema fragment for WFS 2.0.0 and 2.0.2:
<xsd:elementname="GetFeature" type="wfs:GetFeatureType"/>
	<xsd:complexType name="GetFeatureType">
		<xsd:sequence>
			<xsd:elementref="wfs:Query" maxOccurs="unbounded"/>
		</xsd:sequence>
		<xsd:attributename="version" type="xsd:string" use="required" fixed="2.0.2"/>
		<xsd:attributename="service" type="xsd:string" use="required" fixed="WFS"/>
		<xsd:attributename="handle" type="xsd:string" use="optional"/>
		<xsd:attributename="outputFormat" type="xsd:string" use="optional" default="application/gml+xml;version=3.2"/>
		<xsd:attributename="count" type="xsd:positiveInteger" use="optional"/>
	</xsd:complexType>
<xsd:elementname="Query" type="wfs:QueryType"/>
	<xsd:complexType name="QueryType">
		<xsd:sequence>
			<xsd:elementref="ogc:PropertyName" minOccurs="0" maxOccurs="unbounded"/>
			<xsd:elementref="ogc:Filter" minOccurs="0" maxOccurs="1"/>
		</xsd:sequence>
		<xsd:attributename="handle" type="xsd:string" use="optional"/>
		<xsd:attributename="srsName" type="xsd:anyURI " use="optional"/>
		<xsd:attributename="typeNames" type="xsd:QName" use="required"/>
	</xsd:complexType> 

The XML encoding of a GetFeature request is defined by the XML Schema fragment for WFS 1.1.0:


<xsd:elementname="GetFeature" type="wfs:GetFeatureType"/>
<xsd:complexType name="GetFeatureType">
    <xsd:sequence>
        <xsd:elementref="wfs:Query" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attributename="version" type="xsd:string" use="required" fixed="1.1.0"/>
    <xsd:attributename="service" type="xsd:string" use="required" fixed="WFS"/>
    <xsd:attributename="handle" type="xsd:string" use="optional"/>
    <xsd:attributename="outputFormat" type="xsd:string" use="optional" default="text/xml; subtype=gml/3.1.1"/>
    <xsd:attributename="maxFeatures" type="xsd:positiveInteger" use="optional"/>
</xsd:complexType>
<xsd:elementname="Query" type="wfs:QueryType"/>
<xsd:complexType name="QueryType">
    <xsd:sequence>
        <xsd:elementref="ogc:PropertyName" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:elementref="ogc:Filter" minOccurs="0" maxOccurs="1"/>
    </xsd:sequence>
    <xsd:attributename="handle" type="xsd:string" use="optional"/>
    <xsd:attributename="srsName" type="xsd:anyURI " use="optional"/>
    <xsd:attributename="typeName" type="xsd:QName" use="required"/>
    <xsd:attributename="featureVersion" type="xsd:string" use="optional"/>
</xsd:complexType>

The XML encoding of a GetFeature request is defined by the XML Schema fragment for WFS 1.0.0:


<xsd:elementname="GetFeature" type="wfs:GetFeatureType"/>
<xsd:complexType name="GetFeatureType">
    <xsd:sequence>
        <xsd:elementref="wfs:Query" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attributename="version" type="xsd:string" use="required" fixed="1.0.0"/>
    <xsd:attributename="service" type="xsd:string" use="required" fixed="WFS"/>
    <xsd:attributename="handle" type="xsd:string" use="optional"/>
    <xsd:attributename="outputFormat" type="xsd:string" use="optional" default="xmlschema"/>
    <xsd:attributename="maxFeatures" type="xsd:positiveInteger" use="optional"/>
</xsd:complexType>
<xsd:elementname="Query" type="wfs:QueryType"/>
<xsd:complexType name="QueryType">
    <xsd:sequence>
        <xsd:elementref="ogc:PropertyName" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:elementref="ogc:Filter" minOccurs="0" maxOccurs="1"/>
    </xsd:sequence>
    <xsd:attributename="handle" type="xsd:string" use="optional"/>
    <xsd:attributename="srsName" type="xsd:anyURI " use="optional"/>
    <xsd:attributename="typeName" type="xsd:QName" use="required"/>
    <xsd:attributename="featureVersion" type="xsd:string" use="optional"/>
</xsd:complexType>

GET Request

The GET request contains:

Input Required Description
SERVICE=WFS Yes Fixed to WFS.
VERSION= Yes Fixed to 2.0.2. This is the version of the Web Feature Service standard implemented in this release (1.0.0, 1.1.0, 2.0.0, or 2.0.2).
REQUEST=GetFeature Yes Set to GetFeature for a get feature operation.
TYPENAME (1.0.0 or 1.1.0)

TYPENAMES (1.0.0 or 1.1.0)

Yes A comma-separated list of feature types.
MAXFEATURES (1.0.0 or 1.1.0)

COUNT (2.0.0 or 2.0.2)

No The maximum number of features to return.
STARTINDEX No For 2.0.0 and 2.0.2 only.

If both the COUNT and STARTINDEX parameters are set, the response will contain next and previous attributes. These attributes will contain URLs for the next set of results by incrementing or decrementing the STARTINDEX by the COUNT.

For example, for the URL:

http://<server>:<port>/rest/Spatial/WFS?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&STARTINDEX=11&RESULTTYPE=results&COUNT=10&TYPENAMES=ns29:World

The previous attribute would be:

http://<server>:<port>/rest/Spatial/WFS?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&STARTINDEX=1&RESULTTYPE=results&COUNT=10&TYPENAMES=ns29:World

The next attribute would be:

http://<server>:<port>/rest/Spatial/WFS?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&STARTINDEX=21&RESULTTYPE=results&COUNT=10&typenames=ns29:World

OUTPUTFORMAT No Dependent on the version:
  • For 1.0.0, the default is text/xml; subtype=gml/2.1.2.
  • For 1.1.0, the default is text/xml; subtype=gml/3.1.1.
  • For 2.0.0 and 2.0.2, the default is application/gml+xml;version=3.2.
Stored Query For 2.0.0 and 2.0.2 only. Uses the STOREDQUERY_ID and IDparameters. Only the mandatory ID for GetFeatureById is allowed.

Sample GET request:

http://localhost:8097/rest/Spatial/WFS?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&STOREDQUERY_ID=urn:ogc:def:query:OGC-WFS::GetFeatureById&ID=miwfs-2D-World-2D-1

Sample POST request:

<?xml version="1.0" encoding="UTF-8"?>
<wfs:GetFeature version="2.0.2" service="WFS" xmlns:wfs="http://www.opengis.net/wfs/2.0"
 <wfs:StoredQuery id="urn:ogc:def:query:OGC-WFS::GetFeatureById">
  <wfs:Parameter name="id">miwfs-2D-World-2D-1
  </wfs:Parameter>
 </wfs:StoredQuery></wfs:GetFeature>
STOREDQUERY_ID No Version 2.0.0 and 2.0.2 use different id formats (URN versus URL). The URN format is still allowed for 2.0.2 but it has been deprecated.

2.0.0 - urn:ogc:def:query:OGC-WFS::GetFeatureById

2.0.2 - http://www.opengis.net/def/query/OGC-WFS/0/GetFeatureById or urn:ogc:def:query:OGC-WFS::GetFeatureById (deprecated)

ID No The feature ID of the feature to be returned.

For example, the feature ID miwfs-2D-World-2D-1 consists of:

  • miwfs = schema
  • 2D = two-dimensional
  • World = feature name
  • 1 = the feature to return by feature key

For example, for v2.0.2:


http://<server>:<port>/rest/Spatial/WFS?SERVICE=WFS&VERSION=2.0.2&REQUEST=GetFeature&TYPENAMES=World&COUNT=10

For example, for v1.1.0:


http://<server>:<port>/rest/Spatial/WFS?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=World&MAXFEATURES=10