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.

Accordingly specification manipulation with WFS services can be perform using POST or GET (for example, http://demo.opengeo.org/geoserver/wfs?service=wfs&version=1.1.0&request=GetFeature&typeName=topp:states) requests. Is it possible to configure OpenLayers for using only GET requests (by default POST is used). Now my code looks like:

wfs = new OpenLayers.Layer.Vector('Example of WFS layer', {
    strategies: [new OpenLayers.Strategy.BBOX()],
    visibility: true,
    protocol: new OpenLayers.Protocol.WFS(wfs_property)
});
share|improve this question
    
I noticed they changed the default request method after version 2.8 –  OkieOth Dec 4 '12 at 8:51

2 Answers 2

up vote 5 down vote accepted

I've solved my problem. For using GET request should use OpenLayers.Protocol.HTTP instead OpenLayers.Protocol.WFS.

wfs_options = {
    url: 'http://fakeurl/tinyows.cgi?',
    params: {
        request: "GetFeature",
        service: "wfs",
        version: "1.0.0",
        typeName: "layername"
    },
    format: new OpenLayers.Format.GML({
        featureNS: "http://ng.org/sf",
        geometryName: "wkb_geometry"
    })
}

wfs = new OpenLayers.Layer.Vector('WFS', {
    strategies: [new OpenLayers.Strategy.Fixed()],
    visibility: true,
    protocol: new OpenLayers.Protocol.HTTP(wfs_options),
});
share|improve this answer
    
Looks good :-) ... Does your solution also set the parameter for the BBOX values? –  OkieOth Dec 5 '12 at 7:48
    
bbox parameter automatically adds to URL when using BBOX strategy. –  drnextgis Dec 5 '12 at 9:24

A look at the source code seems to show the POST is hard coded in in WFS protocol.

/* part from source with own comments v2.11: lib/OpenLayers/Protocol/WFS/v1.js */
read: function(options) {
    OpenLayers.Protocol.prototype.read.apply(this, arguments);
    options = OpenLayers.Util.extend({}, options);
    OpenLayers.Util.applyDefaults(options, this.options || {});
    var response = new OpenLayers.Protocol.Response({requestType: "read"});

    /* this here seems to be changed - imo it constructs the post xml data */
    var data = OpenLayers.Format.XML.prototype.write.apply(
        this.format, [this.format.writeNode("wfs:GetFeature", options)]
    );

    /* hard coded? */
    response.priv = OpenLayers.Request.POST({
        url: options.url,
        callback: this.createCallback(this.handleRead, response, options),
        params: options.params,
        headers: options.headers,
        data: data
    });

    return response;
},

So my idea try to override the read function with your own WFS protocol implementation. The samples 'lib/OpenLayers/Protocol/WFS/v1_*_0.js' can be a good starting point. You should call it with something like that. wfs = new OpenLayers.Layer.Vector('Example of WFS layer', { strategies: [new OpenLayers.Strategy.BBOX()], visibility: true, protocol: new OpenLayers.Protocol.WFS.v1_withGet(wfs_property) });

But it seems to be the hard way :-D

share|improve this answer

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.