WMS Layer (OGC) non-GIS server. Need help.

2561
7
12-14-2011 01:47 PM
Ravichandran_M_Kaushika
Occasional Contributor
http://myservername.mydomain.com:7575/index?SERVICE=WMS%26Version=1.1.1%26REQUEST=GetMap%26MAX_POINT...

How do I consume this WMS service in my silverlight app. i have visual studio 2010 and used esri's 2.2.0.629 version of silverlight?


ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer
wmsLayer4Lidar = new ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer();
�??
wmsLayer4Lidar.Url = strURLAboveMentionedURL;

myMap.Layers.Add(wmsLayer4Lidar);

it is throwing me a silverlight error after i add the layer - not at that statement - but later.

try catch did not help me. so i went to the script debugger:
errMsg "Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text)
at ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer.client_DownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e)
at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)
at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)
Code: 4004
Category: ManagedRuntimeError
Message: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text)
at ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer.client_DownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e)
at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)
at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)
" String


to begin with, an example to add a WMS with above format would be greatly appreciated in the silverlight samples page.

i am planning to change the URL, break it up and assign appropriate values and then try to add to the map.

in any case, examples or links to example would be great.

thanks and regards
ravi.

0 Kudos
7 Replies
JenniferNery
Esri Regular Contributor
Here's an example of using WMSLayer: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#WmsLayerSimple. Please follow these steps to troubleshoot the layer: http://blogs.esri.com/Dev/blogs/silverlightwpf/archive/2009/08/24/Troubleshooting-blank-layers.aspx. Fiddler might be able to show which web request failed.
0 Kudos
Ravichandran_M_Kaushika
Occasional Contributor
Ms. Jennifer,

good morning.  sorry for the delay in replying to your post.  thanks a lot for the above links.

I got WMS to show up WITH difficulty.  WMS demo link did not say a few things clearly and I had to figure them out myself by trial and error.  some of  these could have been indicated in esri sample wms site.

1.  even tho there was a sample code for http Handler.ashx, i did not need them for a WMS service 1.3.0.

2.  therefore, i did not have to declare a proxyURL.

3. SkipGetCapabilities flag did not mean a thing to code.  it worked both ways.

4. I did not have specify image format.  it worked both ways.

another annoying thing i found was WMS sample page needed a detailed description and it had little or none, where as other simpler example did not need much explanation and they had a detailed explanation.

it is nothing against you - i thank you for trying to help me out.

happy new year and thank you for your time and ever willingness to help people like us.

regards
ravi.


ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer
wmsLayer4Lidar = new ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer();�??
wmsLayer4Lidar.Url =
"http://myServerName.myDomain.Com:7575/ok_sallisawcreek_2006";//&format=image/jpeg";
wmsLayer4Lidar.Version = "1.3.0";
wmsLayer4Lidar.Opacity = 0.5;


wmsLayer4Lidar.Layers = new string[] { "Points" };
wmsLayer4Lidar.ID =
"WMSLidarLayer";
wmsLayer4Lidar.SkipGetCapabilities =
false;
wmsLayer4Lidar.SupportedSpatialReferenceIDs =
new int[] { 3857 };
wmsLayer4Lidar.Visible =
true;
wmsLayer4Lidar.InitializationFailed +=
new EventHandler<EventArgs>(wmsLayer4Lidar_InitializationFailed);
Map.Layers.Add(wmsLayer4Lidar);
0 Kudos
JenniferNery
Esri Regular Contributor
Thank you for your feedback. We are working on our documentation. You can find WMS properties here: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client.Toolkit.DataSources~ESRI.ArcG.... Some properties (as you found) are optional.
0 Kudos
PaulHuppé
Occasional Contributor
Hi,
I am having issues trying to get WMS layers to display also. I have defined a test service using a Canada Lambert COnformal Conic (EPSG 102002) projection and enabled WMS for it. Then, in my Silverlight application, I try to add it to the map in code using:


case"wms":
var wmsLayer = newWmsLayer();
wmsLayer.Url = "http://s5-bsc-ims2.nrn.nrcan.gc.ca/ArcGIS/services/testwms1/MapServer/WMSServer"
;
wmsLayer.ID = "Test WMS Service"
;
wmsLayer.Layers = new string[] { "0" };
wmsLayer.Visible = true;
wmsLayer.SkipGetCapabilities =
true;
wmsLayer.SupportedSpatialReferenceIDs=
new int[] { 102002 };
wmsLayer.Version=
"1.3.0";
layers.Add(wmsLayer);
break;


Later in the code, the layers list is added to the map. In fiddler, when it tries to load the WMS service, I see the following:


GET /ArcGIS/services/testwms1/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetMap&WIDTH=1071&HEIGHT=746&FORMAT=image/png&LAYERS=0&STYLES=&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&VERSION=1.3.0&CRS=EPSG:0&BBOX=-3600246.41388271,-936638.5,4433553.57338271,4659267 HTTP/1.1


This generates an error I can see in Fiddler because it is requesting the service using EPSG code 0 instead of 102002!!!

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><ServiceExceptionReport version="1.3.0"
xmlns="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
<ServiceException code="InvalidCRS">
Parameter 'crs' contains unacceptable value.
</ServiceException>
</ServiceExceptionReport>


So, why is the application sending an EPSG code of 0 when I asked it to use 102002?

Paul
0 Kudos
PaulHuppé
Occasional Contributor
Hi,
I got something working. In my application, if I have a regular dynamic service using the same projection as the first layer and then add the WMS service after, it works and the WMS service shows up.  Before, my first service was not an EPSG 102002 service, but a modified Lambert projection.  Does it mean that I must absolutely have a service using the same projection as the WMS service as my first layer for WMS service to show up?
0 Kudos
PaulHuppé
Occasional Contributor
Hi,
Another thing I noticed, is that if you check the "Use layer names from the map document" for the WMS capabilities of the service and then try using the layer names instead of using the layer numbers, you get nothing back.  Why can't we use the layer names?
0 Kudos
PaulHuppé
Occasional Contributor
Hi,
Another thing I noticed, is that if you check the "Use layer names from the map document" for the WMS capabilities of the service and then try using the layer names instead of using the layer numbers, you get nothing back. Why can't we use the layer names?


Forget about this post, I found my problem, it was a typo! It does work with layer names
0 Kudos