Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've been using the WmsLayer for my WMS Service needs, rather than my old way of doing things by sussing out a GetMap URL and posting that image to a GraphicsLayer. It's been working well but I seem to have found a service that breaks it.

Here is the getCapabilities URL I'm using:

http://ags.pdc.org/arcgis/services/global/pdc_active_hazards/MapServer/WMSServer?SERVICE=WMS&REQUEST=GetCapabilities

I'm able to to get the Name of the layers available (they're using simple numbers to ID them). I provide the WmsLayer the getCapabilitiesURL, the layer ID number & a Proxy Url based upon the proxy handler from the documentation here at ESRI. Unfortunately that doesn't seem to be enough. When debugging, I crash to an unhandled exception as soon as I add it to my map control.

Category: ManagedRuntimeError
Message: System.InvalidOperationException: Sequence contains no elements

Using Firebug to look at my hosted application, it reports this error:

Unhandled Error in Silverlight Application 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 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)

The XML returned by the GetCapabilities call seems sound to me - at least it appears like all of the other WMS services I've been communicating with - so I'm not sure what parsing errors it is running into. Any ideas? I can provide further info if there is something I haven't thought to check.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Okay, so I asked over on the ESRI forums and discovered an interesting... quirk?

I was having an issue adding my WmsLayer dynamically in code. What I have misunderstood, it seems, is that the URL property simply needs the URL to the WMS service endpoint.

So:

wLayer.Url = "http://ags.pdc.org/arcgis/services/global/pdc_active_hazards/MapServer/WMSServer";

Rather than:

wLayer.Url = "http://ags.pdc.org/arcgis/services/global/pdc_active_hazards/MapServer/WMSServer?service=wms&request=getcapabilities";

I've now been going through other WMS servers I've been hitting because I feel certain that I've used URLs with parameters specified and it displayed the overlays just fine. Internally I presume the WmsLayer is sussing out the appropriate getCapabilities and getMap URL strings itself and I was throwing it off by setting those parameters in the URL property.

share|improve this answer

I tried this service in our Silverlight viewer and got this error:

 CRITICAL: Unhandled exception occured: System.InvalidOperationException: Sequence contains no elements

   Details:
      at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
      at ESRI.ArcGIS.Client.Toolkit.DataSources.WmsLayer.ParseCapabilities(XDocument xDoc)
      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)

By looking at the Source for WmsLayer.ParseCapabilities, I see that the API will parse the capabilities differently if it determines that this service is not a WMS 1.3.0 service. I presume that your viewer is doing this - try adding VERSION=1.3.0 to your WMS URL.

share|improve this answer
    
Okay, so I tried adding this parameter and with no luck. I also tried to set the version property of the WmsLayer to 1.3.0 and SkipCapabilities to true. –  Zachary Kane Pride May 18 '12 at 15:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.