Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFS GetFeature via POST #439

Closed
Roel opened this issue Apr 10, 2018 · 3 comments
Closed

WFS GetFeature via POST #439

Roel opened this issue Apr 10, 2018 · 3 comments
Labels

Comments

@Roel
Copy link
Contributor

Roel commented Apr 10, 2018

Is there support for sending WFS GetFeature requests via POST? I'd like to query the WFS service using a prepared WFS GetFeature filter in XML, but I can't get it to work with the current version.

The 'method' parameter seems to suggest it should work:

def getfeature(self, typename=None, filter=None, bbox=None, featureid=None,
featureversion=None, propertyname='*', maxfeatures=None,
srsname=None, outputFormat=None, method='Get',
startindex=None, sortby=None):

But changing this to method='Post' and providing a filter as XML doesn't seem to work.

I think the culprit is in the

data = urlencode(request)

I can prepare a PR to support a (fourth) way of using the GetFeature method, with just a filter (in XML) and method = 'Post'? Like so:

wfs = WebFeatureService(
                url="https://www.dov.vlaanderen.be/geoserver/wfs",
                version="1.1.0")

filter = """<wfs:GetFeature service="WFS" version="1.1.0"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:gml="http://www.opengis.net/gml"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/wfs
                      http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
  <wfs:Query typeName="gw_meetnetten:meetnetten">
    <ogc:Filter>
      <ogc:And>
      <ogc:Within>
        <ogc:PropertyName>geom</ogc:PropertyName>
        <gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#31370"><gml:exterior><gml:LinearRing><gml:posList>145507.928000719 216606.507469683 150613.092722679 214309.409048491 152771.263602172 213891.622205293 151333.251448721 211139.985945256 153660.550282115 211009.519252685 154511.34476093 212074.93472839 153622.622518193 213748.657664443 153597.457095669 215434.484793785 152901.365702482 217023.736349089 151546.817465871 218803.502095865 150001.618076775 220188.887311176 148313.364709693 220881.823122265 146217.66190153 220381.325132092 144289.396255128 220048.65719942 143581.546259324 218986.368908396 145592.876194333 217873.164540651 145507.928000719 216606.507469683</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>
      </ogc:Within>
      <ogc:PropertyIsEqualTo>
      <ogc:PropertyName>gemeente</ogc:PropertyName>
      <ogc:Literal>Mechelen</ogc:Literal>
      </ogc:PropertyIsEqualTo>
      </ogc:And>
    </ogc:Filter>
  </wfs:Query>
</wfs:GetFeature>"""

result = wfs.getfeature(filter=filter, method='Post')

Are we in favor of supporting such a use-case?

@cehbrecht cehbrecht added the wfs label Apr 25, 2018
@huard
Copy link
Contributor

huard commented Jul 24, 2019

We're hitting size limits on our GET feature requests, so having support for POST would be great.

@gilav
Copy link

gilav commented May 9, 2020

Hello

Post is not working for me. Is this issue solved in current branch?

cehbrecht pushed a commit that referenced this issue Nov 26, 2020
* adds quick workaround to make filter post request

Small change to allow testing the use of a xml
query via post.

* adds working draft of getPOSTGetFeatureRequest

* Adds documentation and unimplemented args

Unimplemented args have been added for consistency with
other getfeature functions qui a log warning

* Adds post for wfs 1.1.0 + cleanup

* Refactors __init__ for PostRequest

* removes print command

* adds unit tests for PostRequest_1_1_0

* adds unit test for PostRequest_2_0_0

* add fixtures to postrequest tests

* reformat of __init__ and typo fix

* Formatting

* fix set_featureid according to standard

* Add bbox formating function for post

* fix list args of getPOSTGetFeatureRequest

* Removes repetitive condition

* Removes unused imports

* Add docstring to postrequest.py

* Add featureversion to postrequest.py

* Add storedquery to postrequest.py + refactor

* Remove spaces from tag names

* add test for stored query

* add check to stored query for version

* Modified docstring for storedQueries

* Moved propertyname='*' from def to inside method

For WFS 1.1.0
With Post method now being available, having propertyname='*' as a
default value  causes problems for the post request. Default value
is now None, just like for 2.0.0.

Since I don't know if there are cases where this default was necessary,
added a condition when `method=get` to set propertynames to '*' is
it's not assigned a value.

* Removed uncessary conditional check

* Change docstring for better wording
@huard
Copy link
Contributor

huard commented Nov 26, 2020

This can be closed now with #706.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants