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></codeblock>
<p>The XML encoding of a GetFeature request is defined by the XML Schema fragment for WFS
1.1.0:</p>
<codeblock>
<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)
|
Yes | A comma-separated list of feature types. |
MAXFEATURES (1.0.0 or 1.1.0)
|
No | The maximum number of features to return. |
STARTINDEX |
No | For 2.0.0 and 2.0.2 only. If both the For example, for the URL:
The previous attribute would be:
The next attribute would be:
|
OUTPUTFORMAT |
No | Dependent on the version:
|
Stored Query | For 2.0.0 and 2.0.2 only. Uses the STOREDQUERY_ID and ID parameters. Only the mandatory ID for GetFeatureById is allowed.Sample GET request:
Sample POST request:
|
|
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 -
2.0.2
-
|
ID |
No | The feature ID of the feature to be returned. For example, the feature ID
|
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