Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm using GeoExt, OpenLayers and GeoServer. I've added a checkbox to my layer tree which, when clicked, activates a "select feature" control such that when a user clicks on the map, the feature clicked on is highlighted. My code is:

'checkchange': function(node, checked) { 
                if (checked === true) {
                    app.mapPanel.map.addLayer(node.attributes.layer);
                    mySelectLayer = new OpenLayers.Layer.Vector("Selection", {
                        styleMap: new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
                    });
                    app.mapPanel.map.addLayer(mySelectLayer);

                    myLayerCtrl = new OpenLayers.Control.GetFeature({
                        protocol: OpenLayers.Protocol.WFS.fromWMSLayer(node.attributes.layer),
                        box: true,
                        multipleKey: "shiftKey",
                        toggleKey: "ctrlKey"
                    });
                    myLayerCtrl.events.register("featureselected", this, function(e){
                        mySelectLayer.addFeatures([e.feature]);
                    });
                    app.mapPanel.map.addControl(myLayerCtrl);
                    myLayerCtrl.activate();

                } else {
                    app.mapPanel.map.removeLayer(node.attributes.layer);
                    app.mapPanel.map.removeLayer(mySelectLayer);
                    myLayerCtrl.deactivate();
                }
            }

However, when a user clicks on the map the following exception is thrown by GeoServer:

org.geoserver.platform.ServiceException: No such operation WMS 1.1.0 GetFeature

I've found a number of posts on this, but no solutions. Any idea about what is causing this problem? Thanks in advance.

UPDATE: I've read that this error is as a result of the request being sent to WMS, as opposed to WFS service. My assumption, however, is that it should be possible for OpenLayers to deduce the WFS service. From the OpenLayers documentation here, the protocol parameter kind of takes care of ensuring WFS, and not WMS, is used, in my opinion. Any idea is welcome.

share|improve this question
add comment

1 Answer 1

You are using a wrong url in your protocol; the function

OpenLayers.Protocol.WFS.fromWMSLayer 

doesn't change the url to the geoserver's wfs service (OpenLayers doesn't know that there is Geoserver), which is /wfs. Try to do something like

var protocol = OpenLayers.Protocol.WFS.fromWMSLayer(node.attributes.layer);
protocol.url = '/wfs';   // Add your geoserver base url
share|improve this answer
add comment

Your Answer

 
discard

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.