TerriaJS / terriajs

A library for building rich, web-based geospatial data platforms.
https://terria.io
Apache License 2.0
1.17k stars 362 forks source link

Initial WMS check fails when service returns correct HTTP status code #381

Closed meh9 closed 9 years ago

meh9 commented 10 years ago

When you tick a WMS layer the first thing that appears to happen is that the National Map checks if the service is alive, by doing a GET request on the base URL of the service.

For example, when you turn on the Earthquake Hazard layer, a GET is made to the URL (without any parameters):

http://www.ga.gov.au/gis/services/hazards/EarthquakeHazard/MapServer/WMSServer

The tiles will only be loaded if National Map gets a 200 response.

However, even though the response code is 200, the actual response is this:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1">
  <ServiceException code="InvalidFormat">
    Can't parse XML request.
  </ServiceException>
</ServiceExceptionReport>

But National Map doesn't care, since it got 200 it then proceeds to load the tiles.

This becomes a problem when a WMS actually returns a proper response code for the error, like this one:

http://www.ga.gov.au/thredds/wms/national_grids/radmap10_unfiltered_pctk.nc

When you hit that URL you correctly get a 400 response, since it's not a valid WMS request. Unfortunately this means National Map now will not load the tiles.

If you hit the GetCapabilities URL below you will see that the WMS is actually alive and well:

http://www.ga.gov.au/thredds/wms/national_grids/radmap10_unfiltered_pctk.nc?service=WMS&version=1.3.0&request=GetCapabilities

Perhaps the National Map initial status check should be changed to a GetCapabilities request?

meh9 commented 10 years ago

This is the commit that introduced the service health check, removing it makes the layers load again:

https://github.com/NICTA/nationalmap/commit/0c5f60d760e5d06b655c2963ee4a662a6215d08e

kgrochow commented 10 years ago

I was trying to minimize the overhead of checking the server and a getCapabilities can be quite large and slow. I'll see what else can be done to minimize the overhead.

meh9 commented 10 years ago

I see that you now allow status code 400 on the WMS health check, that's great, and solve many of my layer issues.

Unfortunately GA also has a badly behaved WMS that returns a 500 but if you ignore that it works fine:

http://www.ga.gov.au/gisimg/services/energy/OZTemp_Interpreted_Temperature_at_5km_Depth_Image/ImageServer/WMSServer

Working GetCapabilities:

http://www.ga.gov.au/gisimg/services/energy/OZTemp_Interpreted_Temperature_at_5km_Depth_Image/ImageServer/WMSServer?service=WMS&version=1.3.0&request=GetCapabilities

The simple fix (which I've done locally for now) is obviously to add a 500 case where the check for 400 is performed, but you might want to do something different:

https://github.com/NICTA/aremi-natmap/commit/36eca135dad201f178aa2047b43badab637b1b57