[OpenLayers-Users] OpenLayers WFS with GeoServer

Christopher Schmidt crschmidt at metacarta.com
Mon Mar 24 08:20:59 EDT 2008


On Mon, Mar 24, 2008 at 03:51:10AM -0700, ChrisWebster wrote:
> 
> I'm new to OL, Ajax etc, so I hope you'll excuse this dumb question, but....
> 
> I have OL and GeoServer running on my local machine.  Apache is at
> http://localhost/, and geoServer is on http://localhost:8080/geoserver/.  I
> can load WMS layers from my local GeoServer into a web page on localhost
> using OpenLayers jsut fine.  But if I try to load  a WFS layer into the same
> web page from the same GeoServer instance, I get an error:
> 
> "Permission denied to call method XMLHttpRequest.open"
> 
> The WFS layer seems to be OK if I load it via GeoServer's own demo pages
> (which are running on http://localhost:8080), so as far as I can tell, the
> feature layer and GeoServer are working OK together.  It's when I try to
> load the WFS layer with OpenLayers via my Apache server that things fall
> apart.
> 
> This looks like the usual cross-domain problem, but why should I be getting
> this for the WFS layer if everything works with my WMS layer served via
> exactly the same servers?

WMS tiles are served via <img> tags; <img> is safe, and not subject to
the Same Origin Policy. (Similarly true for Javascript files, which isw
hy you can load http://openlayers.org/api/OpenLayers.js into your app
not hosted on OpenLayers.org.) WFS Tilse are XMLHTtprequests: there is
no other way to get teh data, so it's a violation of the Same origin
policy. 

http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#ProxyHost

has information on how to resolve.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list