[OpenLayers-Users] Making simple WFS GetFeature requests using OpenLayers

Jon Britton jonbritton3 at googlemail.com
Wed Jun 8 06:26:29 EDT 2011


Hi,

I'm trying to use GWT-OpenLayers to carry out some simple WFS requests.
However, I'm having some trouble with OpenLayers not displaying my data.

I'm using GeoServer as my WFS, which names its layers like "sf:roads", where
"sf" is the namespace.  This first example, where I specify the namespace
URL, works fine:

### JAVA CODE ###

WFSProtocolOptions wfsProtocolOptions = new WFSProtocolOptions();
wfsProtocolOptions.setUrl("
http://li199-25.members.linode.com:8080/geoserver/wfs");
wfsProtocolOptions.setFeatureType("roads");
wfsProtocolOptions.setFeatureNameSpace("http://www.openplans.org/spearfish
");
wfsProtocolOptions.setSrsName("EPSG:4326");
wfsProtocolOptions.setVersion("1.1.0");

This results in OpenLayers making the following XML request, which leads to
a valid response which is displayed correctly:

### XML GetFeature REQUEST ###

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version
="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<wfs:Query typeName="feature:roads" srsName="EPSG:4326" xmlns:feature="
http://www.openplans.org/spearfish"></wfs:Query>
</wfs:GetFeature>

However, this next example does not work. Here, I'm only specifying the full
layer title "sf:road" and not specifying the namespace.

### JAVA CODE ###

WFSProtocolOptions wfsProtocolOptions = new WFSProtocolOptions();
wfsProtocolOptions.setUrl("
http://li199-25.members.linode.com:8080/geoserver/wfs");
wfsProtocolOptions.setFeatureType("sf:roads");
wfsProtocolOptions.setSrsName("EPSG:4326");
wfsProtocolOptions.setVersion("1.1.0");

This results in the following XML request being sent. GeoServer handles this
request fine and returns a valid FeatureCollection (as far as I can tell,
it's exactly the same as the previous example).  However, for some reason
OpenLayers just won't display it!

### XML GetFeature REQUEST ###

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS"
version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"><wfs:Query typeName="sf:streams"
srsName="EPSG:4326"/></wfs:GetFeature>

Does anyone have any idea why OpenLayers won't display the results of this
kind of request?

Thanks,

Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110608/6d9617ee/attachment.html


More information about the Users mailing list