This is my XML for a GetFeature request. I want to Sort By FeatureId (fid) but this doesn't work. I can't find an example of how to format this XML correctly:


<?xml version="1.0" encoding="UTF-8"?>
<GetFeature xmlns="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:myws="http://mysrvr.com/solution/myws" xmlns:ogc="http://www.opengis.net/ogc" version="1.1.0" service="WFS" maxFeatures="100" outputFormat="JSON">
   <Query typeName="myws:mylayer">

1 Answer 1


That is not supposed to work. SortBy is defined in the WFS 1.1.0 standard as

The SORTBY parameter is used to specify a list of property names whose values should be used to order (upon presentation) the set of feature instances that satify the query. The value of the SORTBY parameter shall have the form “PropertyName [A|D][,PropertyName [A|D],…]” where the letter A is used to indicate an ascending sort and the letter D is used to indicate a descending sort.

But featureID is not a property and therefore you can't use it with SORTBY. However, with GeoServer you have a workaround and you can publish the primary key which is used for generating featureID also as a normal property. See Why does Geoserver not serve my primary key/ id?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.