Select to view content in your preferred language

WMS layers occassionally failing, not including SRS/CRS in request

2760
14
Jump to solution
10-02-2012 07:20 AM
JeffPace
MVP Alum
using api 3.2

layer = new esri.layers.WMSLayer(lay.url);         layer.setVisibleLayers([lay.catalog]);         layer.setImageFormat("png");         layer.spatialReference = new esri.SpatialReference({wkid:102100});         layer.layerInfos= new esri.layers.WMSLayerInfo({name:lay.label,title:lay.label});         layer.version= "1.1.1";         layer.id= lay.id;


For some reason the request is failing occassionally (inconsistently) because the URL does not include the SRS/CRS (i tried 1.3.0 as well).

FAILS
http://www.mymanatee.org/lizardtech/iserv/ows?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPAREN...

WORKS
http://www.mymanatee.org/lizardtech/iserv/ows?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPAREN...

all i did was manually add the SRS at the end.  But i cannot do this in my code, since its just a navigation event requesting a new tile?
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Deactivated User
using api 3.2

layer = new esri.layers.WMSLayer(lay.url);         layer.setVisibleLayers([lay.catalog]);         layer.setImageFormat("png");         layer.spatialReference = new esri.SpatialReference({wkid:102100});         layer.layerInfos= new esri.layers.WMSLayerInfo({name:lay.label,title:lay.label});         layer.version= "1.1.1";         layer.id= lay.id;


For some reason the request is failing occassionally (inconsistently) because the URL does not include the SRS/CRS (i tried 1.3.0 as well).

FAILS
http://www.mymanatee.org/lizardtech/iserv/ows?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPAREN...

WORKS
http://www.mymanatee.org/lizardtech/iserv/ows?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPAREN...

all i did was manually add the SRS at the end.  But i cannot do this in my code, since its just a navigation event requesting a new tile?


I can't get this to fail:
var wmsLayer = new esri.layers.WMSLayer("http://www.mymanatee.org/lizardtech/iserv/ows"); wmsLayer.setVisibleLayers(["1940"]); map.addLayer(wmsLayer);


Have you got any hints to help it to fail?

-----

As you probably know, the WMS spec changed from 1.1.1 to 1.3.0 with regards to how the coordinate system is stated, it was srs and became crs.

You shouldn't have to worry about this as the correct parameter to send should be worked out by the WMSLayer class based on the GetCapabilities response from the server and its own version compatibility.

IMO, you should not manually specify the version, leave it to the client and server to work out a mutually compatible version, assuming they're both compliant this will happen without any hints from you.  (this should result in the highest possible version being chosen)

Your WMS server claims to be 1.1.1 compliant so it expects "srs".

In a GetMap request the srs/crs parameter is mandatory so if that first URI you supplied was generated by the WMSLayer then something is wrong.

View solution in original post

0 Kudos
14 Replies
__Rich_
Deactivated User
using api 3.2

layer = new esri.layers.WMSLayer(lay.url);         layer.setVisibleLayers([lay.catalog]);         layer.setImageFormat("png");         layer.spatialReference = new esri.SpatialReference({wkid:102100});         layer.layerInfos= new esri.layers.WMSLayerInfo({name:lay.label,title:lay.label});         layer.version= "1.1.1";         layer.id= lay.id;


For some reason the request is failing occassionally (inconsistently) because the URL does not include the SRS/CRS (i tried 1.3.0 as well).

FAILS
http://www.mymanatee.org/lizardtech/iserv/ows?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPAREN...

WORKS
http://www.mymanatee.org/lizardtech/iserv/ows?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/png&TRANSPAREN...

all i did was manually add the SRS at the end.  But i cannot do this in my code, since its just a navigation event requesting a new tile?


I can't get this to fail:
var wmsLayer = new esri.layers.WMSLayer("http://www.mymanatee.org/lizardtech/iserv/ows"); wmsLayer.setVisibleLayers(["1940"]); map.addLayer(wmsLayer);


Have you got any hints to help it to fail?

-----

As you probably know, the WMS spec changed from 1.1.1 to 1.3.0 with regards to how the coordinate system is stated, it was srs and became crs.

You shouldn't have to worry about this as the correct parameter to send should be worked out by the WMSLayer class based on the GetCapabilities response from the server and its own version compatibility.

IMO, you should not manually specify the version, leave it to the client and server to work out a mutually compatible version, assuming they're both compliant this will happen without any hints from you.  (this should result in the highest possible version being chosen)

Your WMS server claims to be 1.1.1 compliant so it expects "srs".

In a GetMap request the srs/crs parameter is mandatory so if that first URI you supplied was generated by the WMSLayer then something is wrong.
0 Kudos
JeffPace
MVP Alum
its a wms layer call

i did the manual layer definition when there where wms errors around 2.8/3.0 .  I will try the other way.
0 Kudos
__Rich_
Deactivated User
its a wms layer call

Oh dear.

i did the manual layer definition when there where wms errors around 2.8/3.0 .  I will try the other way.

Fingers crossed for you...

Oh and as part of my messing around, I wrote some (dodgy) code to automatically add ALL the layers from the service to the map as individual layers (originally it set all the service layers visible in the single layer but it was taking toooo loooong to generate the composite image i.e. some layers are slower than others) you probably have no use for this but...

var wmsLayer = new esri.layers.WMSLayer("http://www.mymanatee.org/lizardtech/iserv/ows");
dojo.connect(wmsLayer, "onLoad", function (lyr) {
    dojo.forEach(lyr.layerInfos, function (info) {
        if (info.name){
            map.addLayer(new esri.layers.WMSLayer(
                lyr.url,
                {
                    visibleLayers: [info.name],
                    //Providing resourceInfo prevents an unnecessary GetCapabilities request
                    resourceInfo:
                    {
                        extent: lyr.extent,
                        layerInfos: lyr.layerInfos,
                        version:lyr.version
                    }
                })
            );
        }
    });
});

^ Just for fun, seems a shame just to bin it! 😉
0 Kudos
JeffPace
MVP Alum
failing seems really random.  It is usually connect to one wms, switch to another and it fails.  i copied the failing uri out of firebug so I am sure that was the request being made.

if i can get a reproducible case i will follow up.

i saw this comment in your code
//Providing resourceInfo prevents an unnecessary GetCapabilities request


can you elaborate?
0 Kudos
__Rich_
Deactivated User
It is usually connect to one wms, switch to another and it fails.

What do you mean "switch"?  e.g. do you re-point an existing layer to a different service or something?
i copied the failing uri out of firebug so I am sure that was the request being made.

I don't doubt it 🙂


i saw this comment in your code

//Providing resourceInfo prevents an unnecessary GetCapabilities request


can you elaborate?


The documentation says:
If resourceInfo is specified a GetCapabilities request is not executed

Since I've already fetched all the resource information for the service once and all the additional layers that I'm instantiating are utilising that service, I don't need to do it again, - just a little efficiency.
0 Kudos
JeffPace
MVP Alum
Maybe it is how i am treating my WMS layers

My application loops through a config file where i have about 12-40 "layers" listed.  They vary in type as tiled, dynamic, and wms.

Each one is added in a loop (addLayer) not (addLayers)

so i add 8 wms layers, all from the same WMS server.  Each time using (bas pseudo code)

layer = new WMS layer
layer.setVisibleLayers([layername])
map.addLayer(layer)

so now I have a map with at least 8 WMS layers in it.
Switching from on (year 2011) to another (1973) is what is occassionally causing the failed request
toggling in my app is a show/hide type event, although layers are also occassionally removed and added back in (same id)
0 Kudos
__Rich_
Deactivated User
Can't see anything wrong per se with the approach you've taken.

I would revisit your manual setting of properties - I had a very brief look through the source code of the layer class earlier and it looks like there is potential for paths through the code that could affect the srs/crs parameter, amongst other things.

We make extensive use of (many) WMS layers but we don't use the WMSLayer supplied with the API, we use a class that I developed in-house (a long time ago, well before the WMSLayer class was added to the API) so I haven't really had to delve into the workings of the ESRI class.
0 Kudos
JeffPace
MVP Alum
I unset alot of properties, not only does it seem to help, but it seems to have sped it up?!

would you be willing to share your class? In particular i am looking to try to make tiled requests of the WMS service.  I have been told express server (lizardtech) supports this if the request is made properly.

thanks again for all the help and guidance!
0 Kudos
__Rich_
Deactivated User
I unset alot of properties, not only does it seem to help, but it seems to have sped it up?!

That sounds like good news 🙂
would you be willing to share your class?

Can't do that I'm afraid, whilst the design/implementation was/is solely mine, the IPR isn't.

In particular i am looking to try to make tiled requests of the WMS service.

Doesn't the WMTSLayer class cover this?
I have been told express server (lizardtech) supports this if the request is made properly.

I'm aware of the standard, but I'm not familiar with that product...what do you mean "properly"?  (or is this the answer my previous question?)
thanks again for all the help and guidance!

You're welcome 🙂  (but I'll be happier when it's working the way you want it to!)
0 Kudos