Skip To Content

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 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.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.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:

http://gisserver.domain.com:6080/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 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 gisserver.domain.com running on port 6080, the URL would be as follows:

http://gisserver.domain.com:6080/arcgis/services/DemoFolder/WFSDemoService/MapServer/WFSServer?service=WFS&request=GetCapabilities

Similarly, if you enabled the WFS capability on a geodata service, the URL would be as follows:

http://gisserver.domain.com:6080/arcgis/services/DemoFolder/WFSDemoService/GeoDataServer/WFSServer?service=WFS&request=GetCapabilities

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.0. WFS 2.0.0 uses version 2.0.0 of the filter specification.

The following table lists the filters you can apply:

GeometrySpatialLogicalComparisonSort

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:

http://gisserver.domain.com: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://gisserver.domain.com: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:

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.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.

URL example: http://gisserver.domain.com:6080/arcgis/services/wfs_services/enterprise_wfs/MapServer/WFSServer?service=WFS&request=GetCapabilities

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

Functionality returned by the GetCapabilities operation

The GetCapabilities operation also returns a list of all available feature classes and tables:

Available feature classes and tables returned by the GetCapabilities operation

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.

URL example: http://gisserver.domain.com:6080/arcgis/services/wfs_services/enterprise_wfs/MapServer/WFSServer?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&VERSION=1.1.0

Feature classes, tables, and field information returned by the DescribeFeatureType operation

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 following example, the DescribeFeatureType request is used to identify the field information for the feature type called continent:

URL example: http://gisserver.domain.com:6080/arcgis/services/wfs_services/enterprise_wfs/MapServer/WFSServer?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TypeName=continent&VERSION=1.1.0

Continent feature class and its field information returned by the filtered DescribeFeatureType operation

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.

URL example: http://gisserver.domain.com:6080/arcgis/services/wfs_services/enterprise_wfs/MapServer/WFSServer?request=getfeature&typename=cities

Attribute and geometry information for the Cities feature class returned by the GetFeature operation

Adding filters

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:

URL example: http://gisserver.domain.com:6080/arcgis/services/wfs_services/enterprise_wfs/MapServer/WFSServer?request=getfeature&typename=cities&BBOX=46.90,-76.21,42.12,-72.88

Cities within the specified coordinate range returned by the filtered GetFeature operation

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:

<wfs:Transaction xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:esri="http://www.esri.com" version = "1.1.0" service="WFS">>
  <wfs:Insert>
    <esri:Cities>
      <esri:NAME>Tofino</esri:NAME>
      <esri:CAPITAL>N</esri:CAPITAL>
      <esri:PROV_NAME>British Columbia</esri:PROV_NAME>
      <esri:POPULATION>12345</esri:POPULATION>
      <esri:RepRowID>1000</esri:RepRowID>
      <esri:Shape>
        <gml:Point>
          <gml:coordinates>59.163182034 -133.844892907</gml:coordinates>
        </gml:Point>
      </esri:Shape>
    </esri:Cities>
  </wfs:Insert>
</wfs:Transaction>

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:

<wfs:Transaction xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xmlns:esri="http://www.esri.com" version = "1.1.0" service="WFS">
  <wfs:Update typeName="esri:cities">
    <wfs:Property>
    <wfs:Name>POPULATION</wfs:Name>
    <wfs:Value>300000</wfs:Value>
  </wfs:Property>
  <ogc:Filter>
    <ogc:PropertyIsEqualTo>
      <ogc:PropertyName>NAME</ogc:PropertyName>
      <ogc:Literal>Halifax</ogc:Literal>
    </ogc:PropertyIsEqualTo>
  </ogc:Filter>
  </wfs:Update>
</wfs:Transaction>

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:

<wfs:Transaction xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ogc="http://www.opengis.net/ogc" xmlns:esri="http://www.esri.com" version = "2.0.0" service="WFS">
  <wfs:Delete typeName="esri:cities">
    <ogc:Filter xmlns:ogc='http://www.opengis.net/ogc'>
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>NAME</ogc:PropertyName>
          <ogc:Literal>Churchill</ogc:Literal>
        </ogc:PropertyIsEqualTo>
    </ogc:Filter>
  </wfs:Delete>
  <wfs:Delete typeName="esri:cities">
    <ogc:Filter xmlns:ogc='http://www.opengis.net/ogc'>
        <ogc:PropertyIsEqualTo>
          <ogc:PropertyName>NAME</ogc:PropertyName>
          <ogc:Literal>Montreal</ogc:Literal>
        </ogc:PropertyIsEqualTo>
    </ogc:Filter>
  </wfs:Delete>
</wfs:Transaction>

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).

Creating a stored query file

A stored query file is an XML file that maintains a list of publisher-authored stored queries relevant for a particular service. To use stored queries with WFS 2.0, create a stored query file and configure the service to reference the URL of your stored queries file.

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.

<?xml version="1.0" encoding="utf-8" ?>
<wfs:StoredQueryList
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns:fes="http://www.opengis.net/fes/2.0"
  xmlns:gml="http://www.opengis.net/gml"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:myns="http://www.someserver.com/myns"
  xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd"
  service="WFS"
  version="2.0.0">

  <wfs:StoredQueryDefinition id="urn:StoredQueries:AttributeDemo">
    <wfs:Title>Attribute request</wfs:Title>
    <wfs:Abstract>test Attribute request</wfs:Abstract>
    <wfs:Parameter name="myrank" type="xsd:double"/>
    <wfs:QueryExpressionText
    returnFeatureTypes="myns:Cities"
    language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
    isPrivate="false">
      <wfs:Query typeName="myns:cities">
        <fes:Filter>
          <fes:PropertyIsEqualTo>
            <fes:Literal>POP_RANK</fes:Literal>
            <fes:Literal>${myrank}</fes:Literal>
          </fes:PropertyIsEqualTo>
        </fes:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>

  <wfs:StoredQueryDefinition id="urn:StoredQueries:SpatialDemo">
      <wfs:Title>Spatial request</wfs:Title>
      <wfs:Abstract>test Spatial Request</wfs:Abstract>
      <wfs:Parameter name="coordinates" type="xsd:string"/>
      <wfs:QueryExpressionText
      returnFeatureTypes="myns:Cities"
      language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
      isPrivate="false">
      <wfs:Query typeName='myns:Cities'>
        <ogc:Filter>
          <ogc:BBOX>
            <ogc:PropertyName>Shape</ogc:PropertyName>
            <gml:Box srsName="urn:x-ogc:def:crs:EPSG:4326">
              <gml:coordinates>${coordinates}</gml:coordinates>
            </gml:Box>
          </ogc:BBOX>
        </ogc:Filter>
      </wfs:Query>
      </wfs:QueryExpressionText>
    </wfs:StoredQueryDefinition>    

  <wfs:StoredQueryDefinition id="urn:StoredQueries:SpatialAndAttributeDemo">
      <wfs:Title>Spatial and Attribute Request</wfs:Title>
      <wfs:Abstract>Select all cities with POP > 12000000 and BBOX (0,0,180,90)</wfs:Abstract>
      <wfs:QueryExpressionText
      returnFeatureTypes="myns:Cities"
      language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
      isPrivate="false">
      <wfs:Query typeName='myns:Cities'>
        <ogc:Filter>
          <fes:And>
            <ogc:BBOX>
              <ogc:PropertyName>Shape</ogc:PropertyName>
              <gml:Box srsName="urn:x-ogc:def:crs:EPSG:4326">
                <gml:coordinates>0,0 90,180</gml:coordinates>
              </gml:Box>
            </ogc:BBOX>
            <fes:PropertyIsGreaterThan>
              <fes:Literal>POP</fes:Literal>
              <fes:Literal>12000000</fes:Literal>
            </fes:PropertyIsGreaterThan>
          </fes:And>
        </ogc:Filter>
      </wfs:Query>
      </wfs:QueryExpressionText>
    </wfs:StoredQueryDefinition>    

  <wfs:StoredQueryDefinition id="urn:StoredQueries:QueryCitiesByID">
    <wfs:Title>Select feature by ID</wfs:Title>
    <wfs:Abstract>test selecting feature by ID</wfs:Abstract>
    <wfs:QueryExpressionText
    returnFeatureTypes="myns:Cities"
    language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
    isPrivate="false">
      <wfs:Query typeName="myns:cities">
        <ogc:Filter>
          <ogc:PropertyIsEqualTo>
            <ogc:Literal>OBJECTID</ogc:Literal>
            <ogc:Literal>${ID}</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>

  <wfs:StoredQueryDefinition id="urn:ogc:def:query:OGC-WFS::GetFeatureById">
    <wfs:Title>urn:ogc:def:query:OGC-WFS::GetFeatureById predefined stored query</wfs:Title>
    <wfs:Abstract>This query support all layers in the map</wfs:Abstract>
    <wfs:QueryExpressionText
    returnFeatureTypes="myns:Cities,myns:Continent,myns:World"
    language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
    isPrivate="false">
      <!-- Cities -->
      <wfs:Query typeName="myns:Cities">
        <ogc:Filter>
          <ogc:PropertyIsEqualTo>
            <ogc:Literal>OBJECTID</ogc:Literal>
            <ogc:Literal>${ID}</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Filter>
      </wfs:Query>
      <!-- Continent -->
      <wfs:Query typeName="myns:Continent">
        <ogc:Filter>
          <ogc:PropertyIsEqualTo>
            <ogc:Literal>OBJECTID</ogc:Literal>
            <ogc:Literal>${ID}</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Filter>
      </wfs:Query>
      <!-- World -->
      <wfs:Query typeName="myns:World">
        <ogc:Filter>
          <ogc:PropertyIsEqualTo>
            <ogc:Literal>OBJECTID</ogc:Literal>
            <ogc:Literal>${ID}</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Filter>
      </wfs:Query>
      <!-- -->
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>

  <wfs:StoredQueryDefinition id="urn:StoredQueries:FunctionCHAR_LENGTH">
    <wfs:Title>Function CHAR_LENGTH</wfs:Title>
    <wfs:Abstract>test Function CHAR_LENGTH</wfs:Abstract>
    <wfs:QueryExpressionText
    returnFeatureTypes="myns:Cities"
    language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
    isPrivate="false">
      <wfs:Query typeName="myns:cities">
        <fes:Filter>
          <fes:PropertyIsEqualTo>
            <fes:Function name="CHAR_LENGTH">
              <fes:Literal>CITY_NAME</fes:Literal>
            </fes:Function>
            <fes:Literal>2</fes:Literal>
          </fes:PropertyIsEqualTo>
        </fes:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>
  <wfs:StoredQueryDefinition id="urn:StoredQueries:FunctionSUBSTRING">
    <wfs:Title>Function CHAR_LENGTH</wfs:Title>
    <wfs:Abstract>test Function CHAR_LENGTH</wfs:Abstract>
    <wfs:QueryExpressionText>
      <wfs:Query typeName="myns:cities">
        <fes:Filter>
          <fes:PropertyIsEqualTo>
            <fes:Function name="SUBSTRING">
              <fes:Literal>CITY_NAME</fes:Literal>
              <fes:Literal>2</fes:Literal>
              <fes:Literal>3</fes:Literal>
            </fes:Function>
            <fes:Literal>os</fes:Literal>
          </fes:PropertyIsEqualTo>
        </fes:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>
  <wfs:StoredQueryDefinition id="urn:StoredQueries:MyStoredQuery">
    <wfs:Title>MyStoredQuery</wfs:Title>
    <wfs:Abstract>some tested MyStoredQuery</wfs:Abstract>
    <wfs:Parameter name="AreaOfInterest" type="gml:PolygonPropertyType"/>
    <wfs:QueryExpressionText
    returnFeatureTypes="myns:Parks myns:Lakes myns:Rivers"
    language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
    isPrivate="false">
      <wfs:Query typeName="myns:cities">
        <ogc:Filter>
          <ogc:Within>
            <ogc:ValueReference>Shape</ogc:ValueReference>
            ${AreaOfInterest}
          </ogc:Within>
        </ogc:Filter>
      </wfs:Query>
      <wfs:Query typeName="myns:cities">
        <ogc:Filter>
          <ogc:PropertyIsEqualTo>
            <ogc:Literal>POP_RANK</ogc:Literal>
            <ogc:Literal>3</ogc:Literal>
          </ogc:PropertyIsEqualTo>
        </ogc:Filter>
      </wfs:Query>
      <wfs:Query typeNames="myns:Parks">
        <fes:Filter>
          <fes:Within>
            <fes:ValueReference>geometry</fes:ValueReference>
            ${AreaOfInterest}
          </fes:Within>
        </fes:Filter>
      </wfs:Query>
      <wfs:Query typeNames="myns:Lakes">
        <fes:Filter>
          <fes:Within>
            <fes:ValueReference>region</fes:ValueReference>
            ${AreaOfInterest}
          </fes:Within>
        </fes:Filter>
      </wfs:Query>
      <wfs:Query typeNames="myns:Rivers">
        <fes:Filter>
          <fes:Within>
            <fes:ValueReference>region</fes:ValueReference>
            ${AreaOfInterest}
          </fes:Within>
        </fes:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>

  <wfs:StoredQueryDefinition id="urn:StoredQueries:FeaturesInPolygon">
      <wfs:Title>Features In Polygon</wfs:Title>
      <wfs:Abstract>Find all the features in a Polygon.</wfs:Abstract>
      <wfs:Parameter name="AreaOfInterest" type="gml:PolygonPropertyType"/>
      <wfs:QueryExpressionText
      returnFeatureTypes="myns:Parks myns:Lakes myns:Rivers"
      language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"
      isPrivate="false">
        <wfs:Query typeNames="myns:Parks">
          <fes:Filter>
            <fes:Within>
              <fes:ValueReference>geometry</fes:ValueReference>
              ${AreaOfInterest}
            </fes:Within>
          </fes:Filter>
        </wfs:Query>
        <wfs:Query typeNames="myns:Lakes">
          <fes:Filter>
            <fes:Within>
              <fes:ValueReference>region</fes:ValueReference>
              ${AreaOfInterest}
            </fes:Within>
          </fes:Filter>
        </wfs:Query>
        <wfs:Query typeNames="myns:Rivers">
          <fes:Filter>
            <fes:Within>
              <fes:ValueReference>region</fes:ValueReference>
              ${AreaOfInterest}
            </fes:Within>
          </fes:Filter>
        </wfs:Query>
      </wfs:QueryExpressionText>
    </wfs:StoredQueryDefinition>    
  </wfs:StoredQueryList>

GetFeatureByID

The GetFeatureByID operation takes a single argument, named id or type xsd:string, and returns a single feature whose identifier is equal to the specified value of the id argument.

The following URL example invokes the GetFeatureByID stored query to retrieve and display a single feature:

http://gisserver.domain.com/arcgis/services/SampleWorldCities/MapServer/WFSServer?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&STOREDQUERY_ID=urn:ogc:def:query:OGC-WFS::GetFeatureById&ID=Cities.1

ListStoredQueries

The ListStoredQueries operation lists the stored queries available on ArcGIS Server. The client can execute one stored query at a time, for example:

http://gisserver.domain.com:6080/arcgis/services/SampleWorldCities/MapServer/WFSServer?request=ListStoredQueries&service=WFS&version=2.0.0

<wfs:ListStoredQueriesResponse version="2.0.0" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.2.1/gml.xsd http://www.opengis.net/ogc http://schemas.opengis.net/filter/2.0/filter.xsd http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsAll.xsd http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/fes/2.0 http://schemas.opengis.net/filter/2.0/filterAll.xsd">
  <wfs:StoredQuery id="urn:StoredQueries:AttributeDemo">
    <ows:Title>Attribute request</ows:Title>
    <ows:Abstract>test Attribute request</ows:Abstract>
  </wfs:StoredQuery>
  <wfs:StoredQuery id="urn:StoredQueries:SpatialDemo">
    <ows:Title>Spatial request</ows:Title>
    <ows:Abstract>test Spatial Request</ows:Abstract>
  </wfs:StoredQuery>
  <wfs:StoredQuery id="urn:StoredQueries:SpatialAndAttributeDemo">
    <ows:Title>Spatial and Attribute Request</ows:Title>
    <ows:Abstract>Select all cities with POP > 12000000 and BBOX (0,0,180,90)</ows:Abstract>
  </wfs:StoredQuery><wfs:StoredQuery id="urn:StoredQueries:QueryCitiesByID">
    <ows:Title>Select feature by ID</ows:Title>
    <ows:Abstract>test selecting feature by ID</ows:Abstract>
  </wfs:StoredQuery>
  <wfs:StoredQuery id="urn:ogc:def:query:OGC-WFS::GetFeatureById">
    <ows:Title>urn:ogc:def:query:OGC-WFS::GetFeatureById predefined stored query</ows:Title>
    <ows:Abstract>This query support all layers in the map</ows:Abstract>
  </wfs:StoredQuery><wfs:StoredQuery id="urn:StoredQueries:FunctionCHAR_LENGTH">
    <ows:Title>Function CHAR_LENGTH</ows:Title>
    <ows:Abstract>test Function CHAR_LENGTH</ows:Abstract>
  </wfs:StoredQuery>
  <wfs:StoredQuery id="urn:StoredQueries:FunctionSUBSTRING">
    <ows:Title>Function CHAR_LENGTH</ows:Title>
    <ows:Abstract>test Function CHAR_LENGTH</ows:Abstract>
  </wfs:StoredQuery>
  <wfs:StoredQuery id="urn:StoredQueries:MyStoredQuery">
    <ows:Title>MyStoredQuery</ows:Title>
    <ows:Abstract>some tested MyStoredQuery</ows:Abstract>
  </wfs:StoredQuery>
  <wfs:StoredQuery id="urn:StoredQueries:FeaturesInPolygon">
    <ows:Title>Features In Polygon</ows:Title>
    <ows:Abstract>Find all the features in a Polygon.</ows:Abstract>
  </wfs:StoredQuery>
</wfs:ListStoredQueriesResponse>

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.

http://gisserver.domain.com:6080/arcgis/services/SampleWorldCities/MapServer/WFSServer?request=DescribeStoredQueries&service=WFS&version=2.0.0

<wfs:DescribeStoredQueriesResponse version="2.0.0" xsi:schemaLocation="http://www.opengis.net/gml http://schemas.opengis.net/gml/3.2.1/gml.xsd http://www.opengis.net/ogc http://schemas.opengis.net/filter/2.0/filter.xsd http://www.opengis.net/ows/1.1 http://schemas.opengis.net/ows/1.1.0/owsAll.xsd http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/fes/2.0 http://schemas.opengis.net/filter/2.0/filterAll.xsd">
  <wfs:StoredQueryDefinition id="urn:StoredQueries:AttributeDemo">
    <wfs:Title>Attribute request</wfs:Title>
    <wfs:Abstract>test Attribute request</wfs:Abstract>
    <wfs:Parameter name="myrank" type="xsd:double"/>
    <wfs:QueryExpressionText returnFeatureTypes="myns:Cities" language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression" isPrivate="false">
      <wfs:Query typeName="myns:cities">
        <fes:Filter>
          <fes:PropertyIsEqualTo>
            <fes:Literal>POP_RANK</fes:Literal>
            <fes:Literal>${myrank}</fes:Literal>
          </fes:PropertyIsEqualTo>
        </fes:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>
  <wfs:StoredQueryDefinition id="urn:StoredQueries:SpatialDemo">
    <wfs:Title>Spatial request</wfs:Title>
    <wfs:Abstract>test Spatial Request</wfs:Abstract>
    <wfs:Parameter name="coordinates" type="xsd:string"/>
    <wfs:QueryExpressionText returnFeatureTypes="myns:Cities" language="urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression" isPrivate="false">
      <wfs:Query typeName="myns:Cities">
        <ogc:Filter>
          <ogc:BBOX>
            <ogc:PropertyName>Shape</ogc:PropertyName>
            <gml:Box srsName="urn:x-ogc:def:crs:EPSG:4326">
              <gml:coordinates>${coordinates}</gml:coordinates>
            </gml:Box>
          </ogc:BBOX>
        </ogc:Filter>
      </wfs:Query>
    </wfs:QueryExpressionText>
  </wfs:StoredQueryDefinition>
</wfs:DescribeStoredQueriesResponse>

Executing a stored query as part of a GetFeature request

The following is an example of an attribute request where a stored query (AttributeDemo) is called using the myrank=3 parameter:

http://gisserver.domain.com:6080/arcgis/services/SampleWorldCities/MapServer/WFSServer?service=WFS&version=2.0.0&REQUEST=GetFeature&typeName=cities&startIndex=0&count=5&STOREDQUERY_ID=urn:StoredQueries:AttributeDemo&myrank=3

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):

http://gisserver.domain.com:6080/arcgis/services/SampleWorldCities/MapServer/WFSServer?service=WFS&version=2.0.0&REQUEST=GetFeature&typeName=cities&startIndex=0&count=2&STOREDQUERY_ID=urn:StoredQueries:SpatialDemo&coordinates=0,-180%2090,0

The following is an example where a stored query (FunctionChat_Length) is called. The stored query on the server is written to filter out cities with name lengths greater than two characters:

http://gisserver.domain.com:6080/arcgis/services/SampleWorldCities/MapServer/WFSServer?service=WFS&version=2.0.0&REQUEST=GetFeature&typeName=Cities&STOREDQUERY_ID=urn:StoredQueries:FunctionCHAR_LENGTH

Response paging

Response paging allows a request to specify the start index of the feature to retrieve. Additionally, a count of the number of features to retrieve can be specified.

Using the SampleWorldCities map service installed with ArcGIS Server, the following query returns two cities (count=2): Brasilia and Goiania:

http://gisserver.domain.com:6080/arcgis/services/SampleWorldCities/MapServer/WFSServer?service=WFS&version=2.0.0&REQUEST=GetFeature&typeName=cities&startIndex=1&count=2

If you change the request and have the startindex begin at 2, the first city returned is Goiania. Since the count=2, two cities now return with the request: Goiania and Campo Grande.

http://gisserver.domain.com:6080/arcgis/services/SampleWorldCities/MapServer/WFSServer?service=WFS&version=2.0.0&REQUEST=GetFeature&typeName=cities&startIndex=2&count=2