Hi everyone,

I am running into a problem with geoserver with which aaime tried to help
me already on irc, but which still doesn't work.

I am trying to use a WFS GeatFeature POST request to work in combination
with the viewparams for an SQL layer (from postgis).

The viewparams work fine when I send WMS GET requests to geoserver. But I
can't get them to work with a WFS GetFeature POST request.

I tried the following things (using python's urllib2 to do the requests).

In the first request, I had the default value of the datasessionid
parameter of my SQL Layer set to 1, which does return results when the
viewparams are absent. In that instance the GetFeature request works fine:

body='''<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; service="WFS"
version="1.1.0" maxFeatures="10"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd";>
  <wfs:Query typeName="viplive_patienten_percentage_cbs_brt_2010"
srsName="EPSG:900913">
    <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc";>
      <ogc:BBOX>
        <ogc:PropertyName>the_geom</ogc:PropertyName>
        <gml:Envelope xmlns:gml="http://www.opengis.net/gml";
srsName="EPSG:900913">
          <gml:lowerCorner>497709.04171597 6827522.0591979</gml:lowerCorner>
          <gml:upperCorner>497756.81485864 6827569.8323406</gml:upperCorner>
        </gml:Envelope>
      </ogc:BBOX>
    </ogc:Filter>
  </wfs:Query>
</wfs:GetFeature>'''

#with the datasessionid parameter set by default to 1 in geoserver:

urllib2.urlopen(urllib2.Request('http://172.17.3.208:8080/geoserver/proigia_gis/wms',headers={'Content-Type':'application/xml;
charset=UTF-8'},data=body)).read()

<wfs:FeatureCollection xmlns:ogc="http://www.opengis.net/ogc";
xmlns:gml="http://www.opengis.net/gml";
xmlns:proigia_gis="http://www.proigia.nl/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xlink="http://www.w3.org/1999/xlink";
xmlns:ows="http://www.opengis.net/ows";
xmlns:wfs="http://www.opengis.net/wfs"; numberOfFeatures="1"
timeStamp="2012-03-23T19:40:33.414+01:00"
xsi:schemaLocation="http://www.proigia.nl/
http://172.17.3.208:8080/geoserver/proigia_gis/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=proigia_gis%3Aviplive_patienten_percentage_cbs_brt_2010
http://www.opengis.net/wfs
http://172.17.3.208:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd";>
  .......a whole lot of GML with a feature...
</wfs:FeatureCollection>
I then set the default value of the datasessionid parameter of the
layer to -1, for which no results will be returned, to test if setting
the datasessionid in the viewparams works.

With a normal WFS get request, it works fine as well:

len(urllib2.urlopen('http://172.17.3.208:8080/geoserver/proigia_gis/wms?LAYERS=proigia_gis%3Aviplive_patienten_percentage_cbs_wijk_2010&FORMAT=image%2Fpng&STYLES=perc_pat_5cat&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A900913&BBOX=490679.22377213%2C6822823.5706164%2C505598.77622787%2C6831150.4293836&WIDTH=1561&HEIGHT=871&viewparams=datasessionid%3A1').read())
76960

I checked the resulting image as well, which looks fine and indeed
contains features.

If I then do a WFS request, stuff fails. As per the instructions of
aime on IRC, I do a POST request, but in the url of the request, I do
specify the viewparams parameter. This isn't used though it seems.


#with the datasessionid parameter set to -1 by default in geoserver

urllib2.urlopen(urllib2.Request('http://172.17.3.208:8080/geoserver/proigia_gis/wms?viewparams=datasessionid%3A1',headers={'Content-Type':'application/xml;
charset=UTF-8'},data=body)).read()


<wfs:FeatureCollection xmlns:ogc="http://www.opengis.net/ogc";
xmlns:gml="http://www.opengis.net/gml";
xmlns:proigia_gis="http://www.proigia.nl/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xlink="http://www.w3.org/1999/xlink";
xmlns:ows="http://www.opengis.net/ows";
xmlns:wfs="http://www.opengis.net/wfs"; numberOfFeatures="0"
timeStamp="2012-03-23T19:55:57.860+01:00"
xsi:schemaLocation="http://www.proigia.nl/
http://172.17.3.208:8080/geoserver/proigia_gis/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=proigia_gis%3Aviplive_patienten_percentage_cbs_brt_2010
http://www.opengis.net/wfs
http://172.17.3.208:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd";>
  <gml:featureMembers/>
</wfs:FeatureCollection>

#the normal wms get request does work though (I saved the image and
checked it as well):


Is there any way to get this to work. I was digging through the sources and
found something I don't really understand:
In java.org.geoserver.wfs.GetFeature.GetFeature.run
I do see a passage:

if(request.getMetadata() != null) {
            viewParams = (List<Map<String, String>>)
request.getMetadata().get(SQL_VIEW_PARAMS);
}

This seems to have something to do with the viewparams in a GetFeature
WFS request, but I can't figure out exactly what it does. I was hoping
I could figure this out myself, or maybe even contribute something to
fix this, but it seems my knowledge of Geoserver is just too little.

I hope someone can help me out.
Cheers,

Dolf.
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to