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

Jon Britton jonbritton3 at googlemail.com
Wed Jun 8 10:52:53 EDT 2011


Hi Ian,

In both cases GeoServer processes the request fine (both Firebug and the
GeoServer logs show this).  Both requests return the same result, in fact
(you can test it using the GeoServer test page).  GeoServer actually uses
the "sf" part of the layer name to find the correct namespace URL. My second
example produces the following in the GeoServer logs:

Request: getFeature
handle = null
service = WFS
 version = 1.1.0
baseUrl = http://li199-25.members.linode.com:8080/geoserver/
 providedVersion = null
extendedProperties = {}
query = [net.opengis.wfs.impl.QueryTypeImpl at 1953684 (group: null,
propertyName: null, function: null, filter: null, sortBy: null,
featureVersion: null, handle: null, srsName: EPSG:4326, typeName: [{
http://www.openplans.org/spearfish}streams])]
 maxFeatures = null
outputFormat = text/xml; subtype=gml/3.1.1
resultType = results
 traverseXlinkDepth = null
traverseXlinkExpiry = null
formatOptions = {}
 metadata = null

As you can see, the typename is [{
http://www.openplans.org/spearfish}streams])].  Again, GeoServer seems to be
handling the request fine so I'm a bit confused as to why it's not showing
in OpenLayers...

Cheers,

Jon

On 8 June 2011 15:44, Ian Turton <ijturton at gmail.com> wrote:

> On 8 June 2011 06:26, Jon Britton <jonbritton3 at googlemail.com> wrote:
> > 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?
>
> It is GeoServer that is refusing to handle the second request not
> OpenLayers (check the log file or firebug) - in the second case you
> have a namespace (sf) that GeoServer can't process since you haven't
> defined it. If you look at the first request you'll see
> xmlns:feature="http://www.openplans.org/spearfish" which is what
> GeoServer uses to work out which roads features you want.
>
> Ian
> --
> Ian Turton
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110608/ea821902/attachment-0001.html


More information about the Users mailing list