Communicating with a WFS service in a web browser
The online resource of each operation supported by a compliant WFS server is an HTTP uniform resource locator (URL), so a WFS service can be considered as a Representational State Transfer (REST) service. Through URL parameters, you can use these operations to obtain service metadata, feature type information, and GML-encoded features from the WFS service. These operations and parameters are detailed in the OGC WFS specification.
Types of clients
WFS services can be used in any client that supports WFS. Most often, a web browser is the simplest client of a WFS service. WFS requests can be issued through HTTP, and the responses or exceptions are returned through the browser. All WFS services support three operations: GetCapabilities, DescribeFeatureType, and GetFeature.
There are many third-party clients available for consuming WFS services. To consume WFS services, the client must support WFS 1.0.0 or 1.1.0 and the Simple Features Profile of GML. Additionally, ArcGIS for Desktop can work with WFS services. For help with using WFS services in ArcMap, see How to work with WFS using ArcGIS for Desktop.
WFS URL structure
To connect to the service, you'll need to know the URL, which follows this pattern:
http://<server name>:<port number>/arcgis/services/<folder name (if applicable)>/<service name>/<service type>/WFSServer?
- The server name is the name of your web server machine.
- The port number is the port your web server machine uses to communicate with other computers.
- The service type can be either MapServer or GeoDataServer, depending on whether you created your WFS service from a map or geodatabase, respectively.
For example, if you enabled the WFS capability on the map service WFSDemoService in a folder called DemoFolder on server myserver running on port 6080, the URL would be as follows:
http://myserver:6080/arcgis/services/DemoFolder/WFSDemoService/MapServer/WFSServer?request=GetCapabilities
Similarly, if you enabled the WFS capability on a geodata service, the URL would be as follows:
http://myserver:6080/arcgis/services/DemoFolder/WFSDemoService/GeoDataServer/WFSServer?
Using filters
The Filter parameter can be used in WFS requests to obtain specific features in a WFS service. The benefit of the Filter parameter is that it’s part of the standard keyword-value pair encoding defined in section 9.5 of the WFS 1.1 Implementation Specification and can be appended at the end of HTTP requests. WFS services use the OGC OpenGIS Filter Encoding Implementation Specification (FE) version 1.1.
These are the filters you can apply:
Geometry |
Spatial |
Logical |
Comparison |
Sort |
---|---|---|---|---|
Envelope |
BBOX |
And |
EqualTo |
SortBy* |
Point |
Equals |
Or |
NotEqualTo | |
MultiPoint |
Disjoint |
Not |
LessThan | |
LineString |
Intersects |
GreaterThan | ||
Polygon |
Crosses |
LessThanOrEqualTo | ||
Touches |
GreaterThanOrEqualTo | |||
Within |
Like | |||
Contains |
Between | |||
Overlaps |
NullCheck |
![Note Note](rsrc/note.png)
*The SortBy filter can only be applied to WFS services that are based on data stored in an ArcSDE geodatabase.
For example, if you created a FeatureType called blockgroups in a WFS service, you could request blockgroup features within extent -122.423192682619, 37.7877919206256, -122.421377806544, 37.7893634225143 by sending the following GetFeature request:
http://myserver:6080/arcgis/services/playground/sanfrancisco_wfs/MapServer/WFSServer?service=WFS&request=GetFeature&version=1.1.0&typename=esri:blockgroups&Filter=<ogc:Filter><ogc:BBOX><ogc:PropertyName>Shape</ogc:PropertyName><gml:Box srsName="urn:x-ogc:def:crs:EPSG:4326"><gml:coordinates>37.7877919206256,-122.423192682619 37.7893634225143,-122.421377806544</gml:coordinates></gml:Box></ogc:BBOX></ogc:Filter>
If you want to request a blockgroups feature that contains a specific point feature, such as 122.431577, 37.749936, you could send the following GetFeature request:
http://myserver:6080/arcgis/services/playground/sanfrancisco_wfs/MapServer/WFSServer?service=WFS&request=GetFeature&version=1.1.0&typename=esri:blockgroups&Filter=<ogc:Filter><ogc:Contains><ogc:PropertyName>Shape</ogc:PropertyName><gml:Point srsName="urn:x-ogc:def:crs:EPSG:4326"><gml:pos srsName="urn:x-ogc:def:crs:EPSG:4326">37.749936 -122.431577</gml:pos></gml:Point></ogc:Contains></ogc:Filter>
![Note Note](rsrc/note.png)
WFS requires involved name space prefixes to be present in the filter XML string. Additionally, to avoid incorrect conversions being completed by web browsers or web servers, URL encode the filter XML string before sending it to the server.
Consuming the WFS service in a web browser
The following examples use URL parameters to communicate with a WFS service in a web browser:
GetCapabilities
This request will return all feature types and functionality available through the service in GML format. To use the GetCapabilities operation, copy and paste the WFS service URL into the address bar and add ?request=getcapabilities to the end of the URL.
URL example: http://myserver:6080/arcgis/services/wfs_services/ArcSDE_wfs/GeoDataServer/WFSServer?request=GetCapabilities
The following graphic is an example of functionality returned by the GetCapabilities operation:
![]() |
GetCapabilities also returns a list of all available feature classes and tables:
![]() |
DescribeFeatureType
This request describes the field information about one or more features in the WFS service. This includes the field names, field types, allowed minimum and maximum field values, and any other constraints set on a field of the feature classes or tables.
To use the DescribeFeatureType operation, copy and paste the WFS URL into the address bar and add ?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&VERSION=1.1.0 to the end of the URL. This will return all the field information about each of the feature types and tables available in the feature service.
URL example: http://myserver:6080/arcgis/services/wfs_services/ArcSDE_wfs/GeoDataServer/WFSServer?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&VERSION=1.1.0
![]() |
Adding filters
You can also specify a single feature class or table that you want the field information for by appending the following request to the end of the URL with the name of the feature type or table:
?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TypeName=<enter feature type here>&VERSION=1.1.0
In the example below, the DescribeFeatureType request is used to identify the field information for the feature type called cities.
URL example: http://myserver:6080/arcgis/services/wfs_services/ArcSDE_wfs/GeoDataServer/WFSServer?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TypeName=cities&VERSION=1.1.0
![]() |
GetFeature
This request returns information about specific feature types available through the WFS service.
To use the GetFeature operation in a web browser, copy and paste the WFS URL into the address bar and add ?request=getFeature&typename=<enter feature type here> to the end of the URL. This will return all the attribute and geometry information about each feature or row in the feature type.
URL example: http://myserver:6080/arcgis/services/wfs_services/ArcSDE_wfs/GeoDataServer/WFSServer?request=getfeature&typename=cities
![]() |
Adding filters
You can also add filters in the request to refine the results that are returned. For example, you can request all the cities that are within a specified coordinate range. In the example below, two cities are located within a specified coordinate range:
URL example: http://myserver:6080/arcgis/services/wfs_services/ArcSDE_wfs/GeoDataServer/WFSServer?request=getfeature&typename=cities&BBOX=46.90,-76.21,42.12,-72.88
![]() |
Working with the FeatureID parameter
The FeatureID parameter can be used in GetFeature requests to request specific features in a WFS service. The FeatureID parameter consists of the feature type and the feature ID (gml:id), not the OBJECTID of the feature. The format of a feature ID for a feature in a WFS service is <FeatureType>.<gml:id>. One method to identify the gml:id of a feature in a WFS service is to do a GetFeature request on the feature type of interest.
![Note Note](rsrc/note.png)
gml:ids are not provided for features in WFS services that are based on shapefiles.
For example, let's say there is a feature type called Cities in a WFS service. If you do a GetFeature request for Cities, the response will include the gml:id for each feature.
URL example: http://myserver:6080/arcgis/services/wfs_services/ArcSDE_wfs/GeoDataServer/WFSServer?request=getfeature&typename=cities
![]() |
In this example, the feature ID for the city of Vancouver would be cities.F293__1. The following request could be used to specifically request the city of Vancouver using the feature ID:
http://myserver:6080/arcgis/services/wfs_services/ArcSDE_wfs/GeoDataServer/WFSServer?request=getfeature&featureid=cities.F293__1