Select to view content in your preferred language

Add WMS Layer without XAML

2608
2
03-26-2011 09:11 AM
JoeWhite
Emerging Contributor
Hi, all,
I'm new to the ESRI Silverlight API, and I've run into a bit of a problem. I'm trying to add WMS layers to my Silverlight app dynamically (read that as without specifying them in the XAML).  I've successfully added dynamic and tiled map layers with no problems, but I run into a problem when adding WMS layers.  WMS Layers from ArcGIS server don't seem to have a problem, but I get exceptions when adding third party WMS layers.

Here is the code for the setup of the layer

                    WmsLayer newLayer = new WmsLayer();
                    newLayer.Url = services.url;
                    newLayer.Initialized += new EventHandler<EventArgs>(newLayer_Initialized);
                    newLayer.ID = services.ServiceName;
                    newLayer.Layers = new String[0]; //this makes all layers invisible
                    Map.Layers.Add(newLayer);

When the layer is initialized, I end up with this exception:
Code : 4004
Message : System.Security.SecurityException: A security exception occurred while connecting to the WMS service.

I've taken that to mean, after doing a little reading, that I need to connect using a proxy, since MS has locked a lot of this type of thing down.  I set the proxyUrl to my proxy I use for GeoRSS feeds, and I get this exception :
Invalid URI: The format of the URI could not be determined.

If anyone out there has a clue as to what I'm doing wrong, please let me know.

Thanks

Joe White
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
Check first that your WMS layer is working if you are adding it with XAML.

Once your layer is working with XAML, the conversion in code should be easy.

If your XAML is working and your code not working, please share both.
0 Kudos
JoeWhite
Emerging Contributor
Sorry for the delay in answering, I've been on vacation.  The XAML works as long as I skip capability checking.  I'm able to add in sublayers as long as I know them by name.  Attempting to check the capabilities of the WMS causes problems similar to what I see if I try to use code to add them dynamically.
0 Kudos