[OpenLayers-Users] Catching WMS errors when using OpenLayers.Layer.WMS... can it be done?

Paul Edwards pjfingers at gmail.com
Thu Jan 26 10:06:01 EST 2012


Hi!

I am working with OpenLayers 2.10 and I have a question regarding error
trapping when using OpenLayers.Layer.WMS (or OpenLayers.Layer.WMS.Post). My
goal is to provide some validation that a WMS layer has been configured
properly and that the custom SLD being dynamically applied is also valid.
I'm open to suggestions as to how to accomplish this, however to date my
efforts have involved setting the EXCEPTIONS parameter in the WMS params to
return application/vnd.ogc.se_xml and then attempting to intercept the WMS
response in order to check. In a success situation the WMS will return a
.gif image. If there's an error the WMS will send the little snippet of XML.

I have included a functional WMS link below that has a deliberate error
with the SLD reference given. I have also included the XML response.

My issue is that I cannot for the life of me figure out how to get my hands
(programmatically speaking of course) on that XML error response when the
tiles are loaded by the OpenLayers.Layer.WMS object. I would like to
intercept the response to the call made by the OpenLayers.Layer.WMS class
to the WMS server when loading the tiles. It appears as if the events
provided that would be of possible use in my case are limited to 'loadend'.
With a little trickery I was able to get a 'tileloaded' event listener to
fire, however both listeners only promote the OpenLayers.Layer.WMS instance
to the listener function and do not give access to the request/response
made to/from the WMS server.

Any thoughts?

Thanks in advance for your help!
Paul


The pertinent params:
SLD=http://somethingbogus
EXCEPTIONS=application/vnd.ogc.se_xml


The URL:

http://mapsdb.nrel.gov/geoserver/wms?LAYERS=topp%3Astates&TRANSPARENT=true&FORMAT=image%2Fgif&LAYER_TYPE=polygon&SLD=http%3A%2F%2Fsomethingbogus&EXCEPTIONS=application%2Fvnd.ogc.se_xml&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A900913&BBOX=-5009376.7456,5009377.424,-2504688.2032,7514065.9664&WIDTH=256&HEIGHT=256


The response:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE
ServiceExceptionReport SYSTEM "
http://mapsdb.nrel.gov:8080/geoserver/schemas/wms/1.1.1/WMS_exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1" >   <ServiceException>
      java.net.UnknownHostException: somethingbogus
somethingbogus
</ServiceException></ServiceExceptionReport>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120126/440f8768/attachment.html


More information about the Users mailing list