[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


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!

The pertinent params:

The URL:


The response:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE
ServiceExceptionReport SYSTEM "
<ServiceExceptionReport version="1.1.1" >   <ServiceException>
      java.net.UnknownHostException: somethingbogus
-------------- 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