AnsweredAssumed Answered

[Bug] WMS layer crashes if the data is invalid

Question asked by bsundsbo on Feb 20, 2014
Latest reply on Feb 20, 2014 by bsundsbo

I'm experiencing a bug with an unhandeled exception using WMS layer. The layer is pointing to an url that returns an invalid result. This causes an unhandled xml exception to occur, interrupting the loading of maps. This also means that the LayersInitialized is not raised. I fixed this in a previous version of the Toolkit.DataSources, and was hoping it would have been fixed in 10.2.

The Url I'm testing against is

The url returns a KMZ file, which is fine for the purpose of reproducing the error. I have noticed from time to time that our customers use a WMS service that sometimes returns invalid xml. Of course they should run against a WMS that always returns proper data, but that is outside of our control. Also, the site might be down, they have lost their internet connection through the proxy, or there could be other reasons why the returned data is not valid xml.

It would be great if you could fix this issue, so I don't have to build my own version of the toolkit whenever I upgrade :)

This is the exception I get.
Unhandeled exception 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)    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)