karlassassin

WmtsLayer loading exception

Discussion created by karlassassin on Apr 18, 2018
Latest reply on Aug 22, 2018 by zalovich89

Hello,there.Sorry about my poor english.

I am adding a  wmtslayer by using the following code.

But there is a exception occurs while WmtsService loading.

The Exception says:Invalid XML.: Parser couldn't move inside Keywords.

 

Here's the call stack:

在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
在 ArcGISRuntime.WPF.Samples.WMTSLayer.WMTSLayer.<Button2_Click>d__2.MoveNext() 位置 C:\Workbench\sources\arcgis-runtime-samples-dotnet-master\src\WPF\ArcGISRuntime.WPF.Viewer\Samples\Layers\WMTSLayer\WMTSLayer.xaml.cs:行号 72

 

Any idea why this exception happens?

You can find the capacities xml from attachment.

             try
            {
                // Define the Uri to the WMTS service
                var myUri = new Uri("http://xxxxx:8080/geoserver/gwc/service/wmts");

                // Define a new instance of the WMTS service
                WmtsService myWmtsService = new WmtsService(myUri);

                // Load the WMTS service
                await myWmtsService.LoadAsync();

                // Get the service information (i.e. metadata) about the WMTS service
                WmtsServiceInfo myWMTSServiceInfo = myWmtsService.ServiceInfo;

                // Obtain the read only list of WMTS layer info objects
                IReadOnlyList<WmtsLayerInfo> myWmtsLayerInfos = myWMTSServiceInfo.LayerInfos;

                // Create a new instance of a WMTS layer using the first item in the read only list of WMTS layer info objects
                WmtsLayer myWmtsLayer = new WmtsLayer(myWmtsLayerInfos[0]);

                // Create a new map
                Map myMap = new Map();

                // Get the basemap from the map
                Basemap myBasemap = myMap.Basemap;

                // Get the layer collection for the base layers
                LayerCollection myLayerCollection = myBasemap.BaseLayers;

                // Add the WMTS layer to the layer collection of the map
                myLayerCollection.Add(myWmtsLayer);

                // Assign the map to the MapView
                MyMapView.Map = myMap;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

 

Thank you!

Outcomes