To define a stored query you have to create a XML file with the query definition. An example from ESRI looks like this:
<CODE><SPAN class=""> <wfs:Abstract></SPAN>This query support all layers in the map<SPAN class=""></wfs:Abstract></SPAN>
<SPAN class=""> <wfs:QueryExpressionText</SPAN> <SPAN class="">returnFeatureTypes=</SPAN><SPAN class="">"myns:Cities,myns:Continent,myns:World"</SPAN>
<SPAN class=""> language=</SPAN><SPAN class="">"urn:ogc:def:queryLanguage:OGC-WFS::WFS_QueryExpression"</SPAN> <SPAN class="">isPrivate=</SPAN><SPAN class="">"false"</SPAN><SPAN class="">></SPAN>
<SPAN class=""> <wfs:Query</SPAN> <SPAN class="">typeName=</SPAN><SPAN class="">"myns:Cities"</SPAN><SPAN class="">></SPAN>
<SPAN class=""> <ogc:Filter></SPAN>
<SPAN class=""><ogc:PropertyIsEqualTo></SPAN>
<SPAN class=""></SPAN><SPAN class=""> <ogc:Literal></SPAN>OBJECTID<SPAN class=""></ogc:Literal></SPAN>
<SPAN class=""> <ogc:Literal></SPAN>${ID}<SPAN class=""></ogc:Literal></SPAN>
<SPAN class=""> </ogc:PropertyIsEqualTo></SPAN>
<SPAN class=""> </ogc:Filter></SPAN>
<SPAN class=""> </wfs:Query>
</SPAN> <SPAN class=""></wfs:StoredQueryDefinition></SPAN>
<SPAN class=""></wfs:StoredQueryList></SPAN><CODE><SPAN class=""><?xml version="1.0" encoding="utf-8" ?>
</SPAN><SPAN class=""><wfs:StoredQueryList</SPAN> <SPAN class="">xmlns:ogc=</SPAN><SPAN class=""><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.opengis.net%2Fogc" target="_blank">http://www.opengis.net/ogc</A><SPAN>"</SPAN></SPAN>
<SPAN class="">xmlns:wfs=</SPAN><SPAN class=""><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.opengis.net%2Fwfs" target="_blank">http://www.opengis.net/wfs</A><SPAN>"</SPAN></SPAN> <SPAN class="">xmlns:fes=</SPAN><SPAN class=""><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.opengis.net%2Ffes%2F2.0" target="_blank">http://www.opengis.net/fes/2.0</A><SPAN>"</SPAN></SPAN>
<SPAN class="">xmlns:gml=</SPAN><SPAN class=""><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.opengis.net%2Fgml" target="_blank">http://www.opengis.net/gml</A><SPAN>"</SPAN></SPAN>
<SPAN class="">xmlns:xsi=</SPAN><SPAN class=""><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</A><SPAN>"</SPAN></SPAN>
<SPAN class="">xmlns:myns=</SPAN><SPAN class=""><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.someserver.com%2Fmyns" target="_blank">http://www.someserver.com/myns</A><SPAN>"</SPAN></SPAN>
<SPAN class="">xsi:schemaLocation=</SPAN><SPAN class=""><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.opengis.net%2Fwfs%2F2.0" target="_blank">http://www.opengis.net/wfs/2.0</A><SPAN> </SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fschemas.opengis.net%2Fwfs%2F2.0%2Fwfs.xsd" target="_blank">http://schemas.opengis.net/wfs/2.0/wfs.xsd</A><SPAN>"</SPAN></SPAN>
<SPAN class="">service=</SPAN><SPAN class="">"WFS"</SPAN> <SPAN class="">version=</SPAN><SPAN class="">"2.0.0"</SPAN><SPAN class="">>
</SPAN> <SPAN class=""><wfs:StoredQueryDefinition</SPAN> <SPAN class="">id=</SPAN><SPAN class="">"urn:ogc:def:query:OGC-WFS::GetFeatureById"</SPAN><SPAN class="">></SPAN>
<SPAN class=""> <wfs:Title></SPAN>urn:ogc:def:query:OGC-WFS::GetFeatureById predefined stored query<SPAN class=""></wfs:Title></SPAN>
<SPAN class=""></SPAN>
The disadvantage of this is, that you have to define it for each and every typeName - everytime a new type is added, you have to add it to the Query. I would like to have a typename="*" or typename="?" - I want to remove the typename. Is this possible?
If not - I still have to add the typename or featureId parameter from the GetFeature request (even so i added the StoredQuery_id=...) otherwise there is an exception. Here is the request:
...- server - name - usw.... /WFSServer?service=WFS&REQUEST=GetFeature&STOREDQUERY_ID=urn:ogc:def:query:OGC-WFS::GetFeatureById&ID=52&typename=layer_name
Is there any possiblity to use this layer_name in the typename in the wfs:Query?