I'm making a simple GetFeatureInfo request against a GeoServer WMS, but it returns empty responses. The request utility I'm using is OpenLayers.loadURL.

The funny thing is, I can paste the generated request URL from FireBug into a new browser tab and get a valid response. So, it seems to be something with the OpenLayers.loadURL. See the examples below.

I can get a valid response with this map event where the GetFeatureInfo request is in a new window:

  map.events.register('click', map, function (e) {
    var url = "http://localhost:8080/geoserver/MYLAYER/wms" 
    var params = "" 
      + "REQUEST=GetFeatureInfo"
      + "&SERVICE=WMS"
      + "&EXCEPTIONS=application/vnd.ogc.se_xml"
      + "&VERSION=1.1.1"
      + "&BBOX=" + map.getExtent().toBBOX()
      + "&X=" + Math.round(e.xy.x)
      + "&Y=" + Math.round(e.xy.y)
      + "&INFO_FORMAT=text/html"
      + "&QUERY_LAYERS=NERD:NERD Risk Rates"
      + "&LAYERS=NERD:NERD Risk Rates"
      + "&FEATURE_COUNT=50"
      + "&format=image/png"
      + "&SRS=EPSG:900913"
      + "&STYLES="
      + "&WIDTH=" + map.size.w
      + "&HEIGHT=" + map.size.h;



However, this map event using OpenLayers.loadURL always returns an empty response and no error. But if I cut and paste the GET request url from FireBug into a new browser window, I get the proper response:

  map.events.register('click', map, function (e) {
    var url = "http://localhost:8080/geoserver/MYLAYER/wms" 

    var paramHash =  {
      REQUEST : "GetFeatureInfo" ,
      EXCEPTIONS : "application/vnd.ogc.se_xml" ,
      SERVICE : "WMS" , 
      VERSION : "1.1.1" ,
      BBOX : map.getExtent().toBBOX() ,
      X : Math.round(e.xy.x) ,
      Y : Math.round(e.xy.y) ,
      INFO_FORMAT : "text/html" , 
      QUERY_LAYERS : "NERD:NERD Risk Rates" , 
      LAYERS : "NERD:NERD Risk Rates" ,
      FEATURE_COUNT : 50 , 
      format : "image/png" ,
      srs : "EPSG:900913" ,
      styles : "" ,
      WIDTH : map.size.w , 
      HEIGHT : map.size.h

    OpenLayers.loadURL(url, paramHash, this, setHTML, setHTML);


Someone have any ideas?


Sounds like a same origin problem to me. Are you serving your page from a different host/port combination than the map server? See http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost for details of how to fix this using a proxy or move your html page to data/web in your geoserver installation.

  • 1
    Yes, you are correct. So now I'm trying to serve my static html page out of apache-tomcat geoserver project as described here docs.geoserver.org/latest/en/user/tutorials/staticfiles.html. There is already html in the directory /var/lib/tomcat6/webapps/geoserver/data/www such as ol-demo.html. I can see this html if i go to localhost:8080/geoserver/www/ol-demo.html. But if i stick my html in this directory and try to go to the URL I only get a 404? Any ideas about that? – maztaz Feb 1 '12 at 12:22
  • /usr/share/opengeo-suite-data not the actual tomcat directory. ugh – maztaz Feb 1 '12 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.