I have written a script using OpenLayers library to get some layers from Geoserver and display them on the map. I use both WMS and WFS layers.
Everything worked fine in my localhost (MAMP) in windows OS.
Now I have to migrate in an UBUNTU 12.10 system. Although I get the WMS correctly, I can not make it to get the WFS.
I used firebug and this is the POST 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="rural:foc_network" srsName="EPSG:4326" xmlns:rural="http://www.opengeospatial.net/rural">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX>
<gml:Envelope xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:lowerCorner>21.831815896484 37.948519811767</gml:lowerCorner>
<gml:upperCorner>22.346800027344 38.120181188719</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
And this the POST response (which is actually the content of my cgi file:
#!/usr/bin/env python
"""This is a blind proxy that we use to get around browser
restrictions that prevent the Javascript from loading pages not on the
same server as the Javascript. This has several problems: it's less
efficient, it might break some sites, and it's a security risk because
people can use this proxy to browse the web and p
In the XML tag of firegu I get this error:
XML Parsing Error: not well-formed Location: moz-nullprincipal:{79ed7c81-0daf-4525-a315-808f0894befd} Line Number 1, Column 2:
#!/usr/bin/env python
Do you have any idea what is going wrong here? Is the path: #!/usr/bin/env python wrongly set? Or what else could be the problem?
And this is my WFS request:
wfs_layer_komvoi = new OpenLayers.Layer.Vector("Κόμβοι", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
url: "http://localhost:8080/geoserver/wfs",
featurePrefix: "rural", //workspace from geoserver
featureType: "komvoi_real", //layer name from geoserver
featureNS : "http://www.opengeospatial.net/rural", //namespace from geoserver
styles: "point"
})
})
Best Answer
There a two or three possible reasons that come to my mind:
Option1: your Webserver is not configured properly:
What happens for example if you try to access this site(presuming that you put your proxy.cgi in your usr/lib/cgi-bin -folder):
http://yourserver_ip_or_adress/cgi-bin/proxy.cgi?url=http://www.openstreetmap.org
If you wont see the openstreetmap-website (without proper styling) than you should have a look at your apache settings.
Here you will find infos: https://httpd.apache.org/docs/2.4/howto/cgi.html#configuring
one option would be to edit your vhosts in
/etc/apache2/sites-enabled/default or /etc/apache2/sites-available/default
where you could add some informations that cgi should be executed: Here is just a simple example how one virtual host definition could look like:
--
Option2 / Option3: Encoding-Problems or cgi not executable:
Try a clean proxy.cgi-"setup":
wget https://raw.githubusercontent.com/openlayers/openlayers/master/examples/proxy.cgi
nano proxy.cgi
make sure it's executable ( for example chmod a+rx /usr/lib/cgi-bin/proxy.cgi )
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";