How to use CIMWFSServiceConnection in ArcGIS Pro

483
2
04-14-2021 12:39 AM
BerendVeldkamp
Occasional Contributor II

Does anyone know how to add a WFS service to a map using the CIMWFSServiceConnection class?

The WMS and WMTS equivalents work perfect, but when using CIMWFSServiceConnection, the layer that's added to the map has a red exclamation mark in front of it, and the Source entry on the layer's properties dialog shows Data source information not available

This is the code I used for adding a WMS service, the only differences are the URL, and the class used in line 2:

 

 

 

var serverConnection = new CIMInternetServerConnection { URL = "https://example.com/wms?service=WMS" };
connection = new CIMWMSServiceConnection { ServerConnection = serverConnection };
LayerFactory.Instance.CreateLayer(connection, MapView.Active.Map);

 

 

 

Adding a WFS through the user interface (i.e. Favorites > Add Item > New WFS Server) also works without problems.

0 Kudos
2 Replies
SrinivasVinnakota
Esri Contributor

Assuming you have a Map instance named "map", try this code snippet:

CIMStandardDataConnection cimStandardDataConnection = new CIMStandardDataConnection
{
  DatasetType = esriDatasetType.esriDTFeatureClass,
  WorkspaceConnectionString = @"SWAPXY=TRUE;SWAPXYFILTER=FALSE;VERSION=2.0.0;URL=https://sampleserver6.arcgisonline.com/arcgis/services/SampleWorldCities/MapServer/WFSServer",
  WorkspaceFactory = WorkspaceFactory.WFS,
  Dataset = "Cities"
};

var wfsLayer = LayerFactory.Instance.CreateLayer(cimStandardDataConnection, map);

 

0 Kudos
BerendVeldkamp
Occasional Contributor II
0 Kudos