HOW TO
ArcGIS Server supports OGC-compliant Web Feature Service (WFS) queries. When retrieving specific features using attribute filters (for example, CITY_NAME = 'Los Angeles'), ArcGIS Server requires the use of an XML-based filter that complies with the OGC Filter Encoding Specification (FES) 2.0 (Filter Encoding Standard – Encoding Syntax for Geospatial Queries), encoded in the FILTER parameter of a GetFeature request.
This article demonstrates how to construct and use such a request using the publicly available SampleWorldCities WFS service.
Using unsupported filters (e.g. CQL_FILTER) or omitting required XML syntax causes errors like InvalidParameterValue or returns unfiltered data.
Retrieve the feature where CITY_NAME = 'Los Angeles' from the Cities layer of the WFS.
Before querying a WFS, it is recommended to inspect its capabilities to identify available layers and supported operations:
https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WFSServer?request=getcapabilities&service=wfs
Once the target layer is known, retrieve its schema to determine the exact attribute names:
https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WFSServer?SERVICE=WFS&VERSION=2.0.0&REQUEST=DescribeFeatureType&TYPENAMES=SampleWorldCities:Cities
The following request returns all features from the Cities layer:
https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WFSServer?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=SampleWorldCities:Cities&SRSNAME=urn:ogc:def:crs:EPSG::4326&OUTPUTFORMAT=geojson
To retrieve only features matching a specific attribute condition (for example, CITY_NAME = 'Los Angeles'), you must include a FES 2.0-compliant XML filter in the FILTER parameter.
<fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0"> <fes:PropertyIsEqualTo> <fes:ValueReference>CITY_NAME</fes:ValueReference> <fes:Literal>Los Angeles</fes:Literal> </fes:PropertyIsEqualTo> </fes:Filter>
The XML filter must be URL-encoded before being appended to the request:
https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WFSServer?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAMES=SampleWorldCities:Cities&SRSNAME=urn:ogc:def:crs:EPSG::4326&OUTPUTFORMAT=geojson&FILTER=%3Cfes%3AFilter%20xmlns%3Afes%3D%22http%3A%2F%2Fwww.opengis.net%2Ffes%2F2.0%22%3E%0A%20%20%3Cfes%3APropertyIsEqualTo%3E%0A%20%20%20%20%3Cfes%3AValueReference%3ECITY_NAME%3C%2Ffes%3AValueReference%3E%0A%20%20%20%20%3Cfes%3ALiteral%3ELos%20Angeles%3C%2Ffes%3ALiteral%3E%0A%20%20%3C%2Ffes%3APropertyIsEqualTo%3E%0A%3C%2Ffes%3AFilter%3E
Article ID: 000037133
Get help from ArcGIS experts
Start chatting now