OkieOth
OkieOth

Reputation: 3714

OpenLayers don't load WFS

I try to load a WFS layer with OpenLayers (v2.12) but unfortunately the load breaks after a HTTP OPTIONS request to my wfs server. FireBug shows my the server sends a empty response. No error are detected. In a older OpenLayers version (v2.8) I use in another application is no OPTIONS request. This old code sends a pure HTTP GET like that:

http://myWfsServer/wfs?typename=someName&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A4326&BBOX=...

Here is the current code

map = new OpenLayers.Map( 'map',{
    maxExtent:OpenLayers.Bounds.fromArray([7,47,10,49]),
    units: 'm'});

layer = new OpenLayers.Layer.OSM( "Simple OSM Map","http://myWfsServer/tiles/${z}/${x}/${y}.png");
map.addLayer(layer);
wfsLayer = new OpenLayers.Layer.Vector("WFS", {
    projection: "EPSG:4326",
    maxExtent: OpenLayers.Bounds.fromArray([7,47,10,49]),
        strategies : [new OpenLayers.Strategy.BBOX()],
        protocol : new OpenLayers.Protocol.WFS.v1_0_0({
        url : "http://myWfsServer/wfs",
        featureType : "ms:lsaId",
        featureNS : "http://mapserver.gis.umn.edu/mapserver",
    format: new OpenLayers.Format.WFST.v1_0_0({
        featureType: "ms:lsaId",
        featureNS: "http://mapserver.gis.umn.edu/mapserver"})
        })
});
map.addLayer(wfsLayer);
map.setCenter(new OpenLayers.LonLat(9,48).transform(
      new OpenLayers.Projection("EPSG:4326"),
      map.getProjectionObject()), 16);    


Question 1: Is there a way to skip this request and go on with the standard GET Request like in earlier OpenLayers versions?

Question 2: What response is expected by OpenLayers?

Upvotes: 1

Views: 1525

Answers (1)

OkieOth
OkieOth

Reputation: 3714

Problem solved. The OPTIONS request comes from the browser not from OpenLayers. Reason for it is the WFS server is not the server provides my web application. This request has something to do with allowing cross-domain access.

To Question 1: Let the application host provide the WFS data. For instance configure Apache as a proxy to the original WFS.

To Question 2: no ideas :-D

Upvotes: 1

Related Questions