0

I'm trying to load a WMS in my application, but I get the following error:

400 (Bad Request)

Confusingly enough I still get an empty image.

The corresponding request is:

http://sg.geodatenzentrum.de/wms_dop40?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=rgb&WIDTH=256&HEIGHT=256&SRS=EPSG:4326&STYLES=&BBOX=112.5,33.75,123.75,45

I've tried setting layer projection parameters to 3857, 4326, 900913 and 25832 but none worked. QGIS also doesn't seem to like the WMS either. So I tried simple getMap requests in my browser and the following worked:

http://sg.geodatenzentrum.de/wms_dop40?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=rgb&WIDTH=256&HEIGHT=256&SRS=EPSG:4326&STYLES=&BBOX=5.625,50.625,11.25,56.25

The only difference I could find was a different BBOX parameter.

Does Openlayers create a wrong BBOX parameter or what do I have to change in my code?

var view = new ol.View({
    center: ol.proj.fromLonLat([10, 51]),
    zoom: 6,
    maxZoom: 11,
    projection: 'EPSG:3857'
});

var luftbilder = new ol.layer.Tile({
    source: new ol.source.TileWMS({
        url: 'http://sg.geodatenzentrum.de/wms_dop40?',
        params: {'LAYERS': 'rgb',
                'VERSION': '1.1.1',
                },
        projection: 'EPSG:4326'

    })  
});

var map = new ol.Map({
    target: 'map',
    view: view,
    layers: [luftbilder]
});

weird, fiddle works fine fiddle (in Chrome)

2

If you are seeing a 400 error from the server then you can't also get an image (blank or otherwise). I see some sort of access control error when I try your links.

BUT

If you check the capabilities document for the WMS you will see the supported bounding box is

<LatLonBoundingBox minx="5.42587260523" miny="46.9672880527" maxx="15.7908768234" maxy="55.1764096793" />

So it seems that your bounding box (BBOX=112.5,33.75,123.75,45) does not intersect the available map data, so you get a blank image.

In any case this will all fail to display (correctly) as you are requesting the map in degrees (epsg:4326) but your map is in meters (epsg:3857). Try removing the projection line in your layer and let the WMS server send the map in the map projection.

  • well my map ist still empty now (and console is still spammed with error 400s). BUT when I open such a requested Tile in a new Browser tab, the tile is loaded correctly. How to fix this? – Revo Sep 4 '17 at 10:58
  • like ignoring error code 400 and still showing the tile? – Revo Sep 4 '17 at 11:44
1

Quite possibly the service is misconfigured, so not necessarily a problem with QGIS or OpenLayers. Certainly if you are getting a 400 error, you should not also be getting an image, the response should be an XML exception.

When I try loading in QGIS, QGIS can read the GetCapabilities response, but won't show the legend, I also can't get the GetLegendGraphic to work as a direct link, so something is wrong with the service.

E.g according to the Capabilities response the following should return a legend:

http://sg.geodatenzentrum.de/wms_dop40?styles=&layer=rgb&service=WMS&format=image/png&sld_version=1.1.0&request=GetLegendGraphic&version=1.1.1&&STYLE=&TRANSPARENT=true

But instead I get an HTTP 400:

<ServiceExceptionReport xmlns="http://www.opengis.net/ogc">
  <ServiceException locator="securityGate.RequestHandler" code="NOACCESS_METHOD GetLegendGraphic">NOACCESS_METHOD GetLegendGraphic</ServiceException>
</ServiceExceptionReport>

QGIS does generate GetMap requests but I only ever get HTTP 400 XML messages like:

<ServiceExceptionReport xmlns="http://www.opengis.net/ogc">
  <ServiceException locator="securityGate.RequestHandler" code="NOACCESS_METHOD GetMap">NOACCESS_METHOD GetMap</ServiceException>
</ServiceExceptionReport>

weird, fiddle works fine

One possibility here is there is some proxying going on in the background; Fiddler is able to handle the redirects, but perhaps QGIS/OpenLayers is not.

Update

I tried too with ArcMap 10.3.1 and get the same error (reads GetCapabilities, GetMap has error).

  • Interesting! does this error mean that my IP is not whitelisted or blocked in a way? How would one implement a way to handle these redirects (probably to the correct wms endpoint, whose url I'm not aware of). – Revo Sep 4 '17 at 15:04
  • 1
    It seems unlikely that the issue is related to white/black listing, as there is a valid GetCapabilities response, and you get some response with Fiddler. Additionally if the issue is one access, then I would expect some other HTTP response (401, 403, 407, 412...). – nmtoken Sep 4 '17 at 16:17
  • 1
    According to the GetCapabilities response, contact for the service is dlz@bkg.bund.de I would enquire there if there are any restrictions on the service, or a different access URL – nmtoken Sep 4 '17 at 16:20

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.