[GIS] How to i filter on ID’s through WFS Post request

filtergeoserverwfsxml

I want to select a set of features from my GeoServer (its Running 2.0.0) and use a query using multiple ID's to get their values. For this i send XML in a post message to the Geoserver:

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" service="WFS" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" maxFeatures= "7000" >
    <wfs:Query typeName="*:MyFeatures_df16" xmlns:feature="http://www.openplans.org/topp">
        <ogc:Filter>
            <ogc:And>
                <ogc:OR>
                    <PropertyIsEqualTo>
                        <PropertyName>ID</PropertyName>
                        <Literal>98400005701</Literal>
                    </PropertyIsEqualTo>
                    <PropertyIsEqualTo>
                        <PropertyName>ID</PropertyName>
                        <Literal>-1</Literal>
                    </PropertyIsEqualTo>
                </ogc:OR>
                <ogc:And>
                    <ogc:PropertyIsLessThanOrEqualTo>
                        <ogc:PropertyName>MH_DATUM_INGANG</ogc:PropertyName>
                        <ogc:Literal>2015-02-27T00:00:00Z</ogc:Literal>
                    </ogc:PropertyIsLessThanOrEqualTo>
                    <ogc:Or>
                        <ogc:PropertyIsGreaterThanOrEqualTo>
                            <ogc:PropertyName>MH_DATUM_EINDE</ogc:PropertyName>
                            <ogc:Literal>2015-02-27T00:00:00Z</ogc:Literal>
                        </ogc:PropertyIsGreaterThanOrEqualTo>
                        <ogc:PropertyIsNull>
                            <ogc:PropertyName>MH_DATUM_EINDE</ogc:PropertyName>
                        </ogc:PropertyIsNull>
                    </ogc:Or>
                </ogc:And>
            </ogc:And>
        </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

The filter based on the date (MH_DATUM_BEGIN/MH_DATUM_EIND) is working as expected. But the filter using is completly ignored.
One of the returns includes:

<gml:featureMember>
      <ws_df16:MyFeatures_df16 fid="MyFeatures_df16.fid--7d7f79e6_14bcb33c65d_161">
         <ws_df16:GEOMETRIE>
            <gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#28992">
               <gml:outerBoundaryIs>
                  <gml:LinearRing>
                     <gml:coordinates decimal="." cs="," ts=" ">197089.235,393933.984 197059.285,393941.753 197057.851,393936.587 197061.768,393935.646 197059.436,393926.758 197062.756,393925.888 197062.109,393923.534 197071.095,393921.174 197072.634,393927.002 197074.054,393932.378 197084.891,393929.538 197087.87,393928.757 197089.235,393933.984</gml:coordinates>
                  </gml:LinearRing>
               </gml:outerBoundaryIs>
            </gml:Polygon>
         </ws_df16:GEOMETRIE>
         <ws_df16:ID>98400007766</ws_df16:ID>
         <ws_df16:MH_DATUM_INGANG>2010-01-01</ws_df16:MH_DATUM_INGANG>
         <ws_df16:GIS_ID>288830</ws_df16:GIS_ID>
      </ws_df16:MyFeatures_df16>
   </gml:featureMember>

In this part of the response, the Date is correct(like all of the answers) but it returns all of the thousands of features in GeoServer.
I want to select that specific ID because it is used in other parts of a larger application.

How can i make sure that my filter query is used as well?

Best Answer

Fixed it by adding the ogc: namespace to: PropertyIsEqualTo, PropertyName and Literal:

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" service="WFS" version="1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" maxFeatures= "13" >
    <wfs:Query typeName="*:MyFeatures_df16" xmlns:feature="http://www.openplans.org/topp">
        <ogc:Filter>
            <ogc:And>
                <ogc:Or>
                    <ogc:PropertyIsEqualTo>
                        <ogc:PropertyName>ID</ogc:PropertyName>
                        <ogc:Literal>98400005701</ogc:Literal>
                    </ogc:PropertyIsEqualTo>
                    <ogc:PropertyIsEqualTo>
                        <ogc:PropertyName>ID</ogc:PropertyName>
                        <ogc:Literal>98400005701</ogc:Literal>
                    </ogc:PropertyIsEqualTo>
                </ogc:Or>
                <ogc:And>
                    <ogc:PropertyIsLessThanOrEqualTo>
                        <ogc:PropertyName>MH_DATUM_INGANG</ogc:PropertyName>
                        <ogc:Literal>2015-03-02T00:00:00Z</ogc:Literal>
                    </ogc:PropertyIsLessThanOrEqualTo>
                    <ogc:Or>
                        <ogc:PropertyIsGreaterThanOrEqualTo>
                            <ogc:PropertyName>MH_DATUM_EINDE</ogc:PropertyName>
                            <ogc:Literal>2015-03-02T00:00:00Z</ogc:Literal>
                        </ogc:PropertyIsGreaterThanOrEqualTo>
                        <ogc:PropertyIsNull>
                            <ogc:PropertyName>MH_DATUM_EINDE</ogc:PropertyName>
                        </ogc:PropertyIsNull>
                    </ogc:Or>
                </ogc:And>
            </ogc:And>
        </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

It does return the coordinates in a diffrent layout, but all the needed filters work!