Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to add a vector layer with a wfs layer and it's not working.Can anyone point a solution?

Openlayers code:

var wfs = new OpenLayers.Layer.Vector(
                "Stavros Features",
                    strategies: [new OpenLayers.Strategy.BBOX()]
                    ,projection: new OpenLayers.Projection("EPSG:4326")
                    ,protocol: new OpenLayers.Protocol.WFS({
                        version: "1.1.0"
                        ,srsName: "EPSG:4326"
                        ,url: "http://localhost:8080/geoserver/wfs"
                        ,featureNS :  ""
                        ,featureType: "polygon"
                        ,geometryName: "the_geom"

In the geoserver i have a workspace 'myWorkspace', a store 'myStore' and a layer 'myLayer' and wfs is enabled. Also in the 'publishing' tab of my layer in the 'WMS Settings Default Style' i have selected 'polygon' as myLayer is multipolygon.

What am i doing wrong?
Am i suppose to specify the workspace name in the 'featureNS' property?

Is there a good tutorial for open layers?
I have read the docs which are very poor and the examples doesn't help me always. I have also read the user manual of geoserver and i found it very good.


share|improve this question
Is your OpenLayers application is running on port 80 or port 8080? – geographika Jul 13 '11 at 15:11
can you see the result of the request in firebug? – iant Jul 14 '11 at 10:50

Okay few things i would change and give another try:

  1. Make sure your featureNS value is in the "Edit Workspace Page under Namespace URI" in your GEOSERVER. Do not use something as generic as "". Use something like "http://yourdomain/application/catalogLayer" or something unique like that. You can make this URI up, just make it unique.
  2. You have new BBOX() as a strategy but what do that box have as dimensions? I would change it to [new OpenLayers.Strategy.Fixed()] for testing.
  3. featureType is not actually the type of geometry, it's your "Layer Name" in GEOSERVER (i know, misleading).
  4. geometryName is the name of the field in your postgis database that has the Geometry data type. In GEOSERVER, Under "Edit Layer" you can see at the bottom "Feature Type details". There you will see a field with type "Geometry". Use the value under the property column.


enter image description here


enter image description here


enter image description here

share|improve this answer
Great job, thanks for sharing that. I've found it's imperative to set the NS to be correct, and NOT to use special characters like : in the names of layers. – JayCrossler Jan 31 '13 at 2:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.