Monday, April 14, 2008

openlayers wms manager error on iis

The WMS Manager library for openlayers is a great tool for allowing users to dynamically select layers from one or many wms servers. While demonstrating setup of this library on our localhost for the advanced gis class I teach, I came across a confounding error "Unhandled Request return Object Not Found."

The example page I am attempting to view is at "lib/openlayers/examples/wms_manager.html"

First, an aside of sorts: This error was actually one of many due to some issues with paths (in the WMS manager example versus our local version). To avoid this error get an openlayers install with WMS manager and required libraries already integrated. You can find this on SVN at: http://svn.openlayers.org/sandbox/ominiverdi/openlayers (you can use a SVN program like tortoise for windows.

This error occurs because you do not have a proxy host defined. A proxyhost is necessary when making sending a request to a remote host from javascript, since javascript is not normally allowed to do that.

Openlayers comes with a proxyhost cgi called proxy.cgi which is located in the examples directory. If your server is not setup to run python cgi's you must do so now. If you are running windows 2000 or have experience with iis (and/or have already installed python on your machine) I recommend this tutorial, if you are installing on windows server 2003 check out this one. If those don't get you going here is the one from microsoft with each and every step. The funny thing about the microsoft tutorial is that they actually give a non-working example to test your iis-python-cgi install, which causes your browser to attempt to save the test file every time you try to access it. Use the example here ("Problem 3") to correct that issue

Once you have IIS set up to deal with python cgi's, drag the proxy.cgi file into your new cgi-bin folder. Finally change OpenLayers.ProxyHost = "http://localhost/cgi-bin/proxy.cgi?url=" (if your cgi is at the root of your localhost like mine). For WMS manager you must change this variable in "/lib/OpenLayers/Ajax.js " and in "lib/openlayers/examples/wms_manager.html"

But, lo, you may find yourself stuck with an "Unhandled request return Bad Gateway" error when you try to pull up a wms host -- NO NEED TO WORRY -- this error occurs when you have not yet added the host to your proxy.cgi file. Just open up that baby and stick your desired host name in there and you should be good to go (just try another wms host to see it work if you don't believe me).

1 comment:

mabdulhadi said...

Thank you very much for such
I have modified my proxy.cgi as you have mentioned. and setup python in IIS 6.0 Windows Server 2003 SP1

I am having problem in using it behind our corporate firewall (ISA Server) with authentication.

I searched and tried several approaches (like this,this,this,this and this) to get authenticated by ISA Server Basic HTTP Authentication. But I don't know what I am missing either I get 407 error or a timeout error.

Any help would be highly appreciated.