Communicating with a WFS service in a web browser

In this topic

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 basic 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 primary operations: GetCapabilities, DescribeFeatureType, and GetFeature. The ArcGIS Server implementation of WFS 2.0 defines additional operations: GetFeatureByID, ListStoredQueries, and DescribeStoredQueries.

There are many third-party clients available for consuming WFS services. To consume WFS services, the client must support WFS 1.0.0, 1.1.0, or 2.0 and the Simple Features Profile of GML. Additionally, ArcGIS Desktop can work with WFS services. For help with WFS services in ArcMap, see Adding a WFS service to ArcMap.

WFS URL structure

To connect to the service, you need to know the URL, which follows this pattern:

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 1.0.0 and 1.1.0 services use the OGC OpenGIS Filter Encoding Implementation Specification (FE) version 1.1. WFS 2.0 uses version 2.0 of the filter specification.

The following table lists 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:

*The SortBy filter can only be applied to WFS services based on data stored in an enterprise 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:

Note:

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, the URL encodes the filter XML string before sending it to the server.

Consuming a WFS 1.0.0 or 1.1.0 service in a web browser

The following examples use URL parameters to communicate with WFS and WFS-T 1.0.0 and 1.1.0 services in a web browser. To learn how to use WFS 2.0 operations in a web browser, see the Consuming a WFS 2.0 service in a web browser section below.

GetCapabilities

This request returns 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 ?service=WFS&request=getcapabilities to the end of the URL.

The following graphic is an example of functionality returned by the GetCapabilities operation:

The GetCapabilities operation 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 returns all the field information about each of the feature types and tables available in the feature service.

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 returns all the attribute and geometry information about each feature or row in the feature type.

You can also add filters in the request to refine the returned results. For example, you can request all the cities within a specified coordinate range. In the following example, three cities are located within a specified coordinate range:

Insert

Insert is used to create new features in a single transaction request. By default, the initial state of a feature to be created is expressed using GML3 and must validate relative to a GML3 application schema generated by the DescribeFeatureType operation.

For example, the following sample inserts a point feature representing a city:

Update

Update is used to update a feature or features (of a single type) in a single transaction request.

The <Update> element contains one or more <Property> elements that specify the name and replacement value for a property that belongs to the feature type specified using the mandatory typeName attribute. A <Property> element contains a <Name> element that contains the name of the feature property to be modified and an optional <Value> element that contains the replacement value for the named feature property. The omission of the <Value> element means that the property should be assigned a NULL value. In the event that the property is not nullable, the WFS must raise an exception indicating that the NULL value is not allowed.

For example, the following sample updates a point feature in a dataset called cities:

Delete

Delete is used to delete one or more features (of a single type) in a single transaction request. Delete is defined using the <Filter> element. In the event that the <Filter> element does not identify any feature instances to delete, the delete request is ignored.

For example, the following sample deletes two features in a dataset called cities:

Consuming a WFS 2.0 service in a web browser

The ArcGIS Server implementation of the WFS 2.0 specification addresses the required features of the basic WFS profile, as stated in the WFS 2.0 specification. This includes the GetCapabilities, DescribeFeatureType, and GetFeature operations (described above). The WFS 2.0 implementation also supports transactions, stored queries, and response paging, which are not part of the basic WFS profile.

Transactions

The Transaction operation is used to describe data transformation operations applied to feature instances in a WFS service. Using the Transaction operation, clients can create, modify, replace, and delete features in the WFS. When the transaction completes, the WFS generates an XML response document indicating the completion status of the operation.

Stored queries

Stored queries allow complex filter queries to be stored by WFS 2.0 and executed using a basic request. To achieve the same result with WFS 1.0.0 or 1.1.0, you would have to write a filter using a filter encoding specification and append it to the WFS URL. Configuring stored queries gives you the following benefits that broaden the use of WFS 2.0 in applications:

Complex queries can be streamlined so they can be
executed as HTTP GET requests.

A WFS can be implemented to support only stored queries so the
administrator can control how users access the data.

Stored queries can reduce costs for development of applications since
they can be configured to support specific queries rather than
complex ad hoc queries and XPath expressions.

RESTful interfaces can be established on top of the WFS alongside
HTTP GET/POST and SOAP to enable the WFS to be used within
lightweight client applications.

The following operations are available to support stored queries: GetFeatureByID, ListStoredQueries, and DescribeStoredQueries (described below).

The following example stored query file works with the SampleWorldCities map service included with ArcGIS Server. You can create the file and configure the service to use it following the instructions in Configuring a WFS service to use stored queries. You can also modify the file to work with a different WFS service.

DescribeStoredQueries

The DescribeStoredQueries operation describes the stored queries available on ArcGIS Server. This operation is useful for WFS clients to interrogate the server, and to understand the nature of the stored query and the parameters that need to be sent to execute the stored query.

The following is an example where a stored query (SpatialDemo) is called using the coordinates parameter to retrieve a list of U.S. cities that fall within a bounding box. Only the first two cities are returned from this list (note the use of startindex and count):