Select to view content in your preferred language

Add WMS Layer. Error 23. "Invalid XML"

123
4
Jump to solution
Wednesday
DanielGaston
New Contributor

Hi,
In a sample app with just a single map, I am trying to load a WMS layer with the next parameters

let wmsServiceURL = URL(string: "https://my_geoserver.com?version=1.1.0")!
let wmsServiceLayerNames = ["my_layer_name"]

// initialize the WMS layer with the service URL and uniquely identifying WMS layer names
let wmsLayer = AGSWMSLayer(url: wmsServiceURL, layerNames: wmsServiceLayerNames)

// load the WMS layer
wmsLayer.load { [weak self] (error) in
       if let error = error {
           print(error)
       } else if wmsLayer.loadStatus == .loaded {
           // add the WMS layer to the map
           map.operationalLayers.add(wmsLayer)
       }
}

 
No matter if I add the query param with version 1.1.0 or not, I always receive the following error:

 

Error Domain=com.esri.arcgis.runtime.error Code=23 "Invalid XML." UserInfo={NSLocalizedFailureReason=Error processing WMS service XML response.
XML comment is not well-formed., NSLocalizedDescription=Invalid XML., Additional Message=Error processing WMS service XML response.
XML comment is not well-formed.}

The server response is a valid XML, tested in multiple validators.

I have used a proxy as well for testing purposes just to isolated the layer I want to load from the multiple I receive in the GetCapabilities server response, but unfortunately I get the same error 23 with no further explanation.

Could you help me? Do you have an idea of what is going on?
Than you in advance

0 Kudos
1 Solution

Accepted Solutions
MatveiStefarov
Esri Contributor

I narrowed down the problem: there is a bug in the XML parser that is triggered when a `CDATA` section contains `]` in its text.  This bug was fixed in ArcGIS Maps SDK version 200.4.0.

I'm afraid 100.15.x is now out of support, and will not receive further updates.  Your best bet would be to upgrade to 200.8.0, which is a long-term supported release that already fixes this issue, and will continue to receive patches for a couple more years.

If you need an immediate workaround, you can: 1) download the capabilities XML, 2) edit the problematic CDATA sections to avoid brackets, and then 3) self-host the edited capabilities document somewhere.  For example, here is a copy I made just by search-and-replacing "[°C]" with "(°C)".  It loads for me even in old versions of ArcGISRuntime: gist.githubusercontent.com/mstefarov/98e60a5aefb0512ae5b33ab9f2c1212e/raw/5b4e5bbce6673a74bc9f71393b...

This workaround is possible because the WMS standard is quite flexible: you can edit and host the capabilities document anywhere, and it will still link to map data from the original server.

View solution in original post

4 Replies
MatveiStefarov
Esri Contributor

Hello Daniel,

Which version of Runtime/Maps SDK are you on?

I tested this layer with latest released version of ArcGIS Maps SDK for .NET (200.8.0) and the service appeared to be working:

 

2025-10-29_023916.png

 

It's possible that there is some platform-specific issue here, so I will check with the Swift team as well.

0 Kudos
DanielGaston
New Contributor

argis-runtime-ios 100.15.6
the point is I have to make it work with that legacy version (otherwise I need to migrate the whole project to the 2xx)

0 Kudos
MatveiStefarov
Esri Contributor

I narrowed down the problem: there is a bug in the XML parser that is triggered when a `CDATA` section contains `]` in its text.  This bug was fixed in ArcGIS Maps SDK version 200.4.0.

I'm afraid 100.15.x is now out of support, and will not receive further updates.  Your best bet would be to upgrade to 200.8.0, which is a long-term supported release that already fixes this issue, and will continue to receive patches for a couple more years.

If you need an immediate workaround, you can: 1) download the capabilities XML, 2) edit the problematic CDATA sections to avoid brackets, and then 3) self-host the edited capabilities document somewhere.  For example, here is a copy I made just by search-and-replacing "[°C]" with "(°C)".  It loads for me even in old versions of ArcGISRuntime: gist.githubusercontent.com/mstefarov/98e60a5aefb0512ae5b33ab9f2c1212e/raw/5b4e5bbce6673a74bc9f71393b...

This workaround is possible because the WMS standard is quite flexible: you can edit and host the capabilities document anywhere, and it will still link to map data from the original server.

DanielGaston
New Contributor

Thank you!
I appreciate it

0 Kudos