

public sealed class ServerConnectionProjectItem : ArcGIS.Desktop.Internal.Catalog.ProjectItemInfoCrawl, ArcGIS.Desktop.Core.IMetadata, ArcGIS.Desktop.Core.IProjectItem, ArcGIS.Desktop.Core.IProjectMultiItem, System.ComponentModel.INotifyPropertyChanged
Public NotInheritable Class ServerConnectionProjectItem Inherits ArcGIS.Desktop.Internal.Catalog.ProjectItemInfoCrawl Implements ArcGIS.Desktop.Core.IMetadata, ArcGIS.Desktop.Core.IProjectItem, ArcGIS.Desktop.Core.IProjectMultiItem, System.ComponentModel.INotifyPropertyChanged
A server connection project item is a connection to an ArcGIS Server site, an OGC WMS service, or an OGC WMTS service that has been added to the current project. New server connections cannot be created, but an existing .ags, .wms, or .wmts file containing connection information can be added to a project.
/// Get all the server connections in a project
IEnumerable<ServerConnectionProjectItem> projectServers = Project.Current.GetItems<ServerConnectionProjectItem>();
IEnumerable<ServerConnectionProjectItem> newServerConnections = null; newServerConnections = project.GetItems<ServerConnectionProjectItem>(); foreach (var serverItem in newServerConnections) { //Do Something with the server connection. }
ServerConnectionProjectItem serverProjItem = Project.Current.GetItems<ServerConnectionProjectItem>().FirstOrDefault(item => item.Name.Equals("myServer"));
//This workflow would work for var agsFilePath = @"C:\Data\ServerConnectionFiles\AcmeSampleService.ags"; //ServerConnectionProjectItem supports .ags, .wms, .wmts, .wfs, and .wcs files var server_conn_item = ItemFactory.Instance.Create(agsFilePath) as ArcGIS.Desktop.Catalog.ServerConnectionProjectItem; //Get the server connection - passwords are never returned var serverConnection = server_conn_item.ServerConnection as CIMProjectServerConnection; //Add to an AGS service connection var service_connection = new CIMAGSServiceConnection() { URL = "URL to the AGS _service_ on the AGS _server_", ServerConnection = serverConnection }; // Add a new layer to the map var layerParams = new LayerCreationParams(service_connection); layerParams.MapMemberPosition = MapMemberPosition.AddToBottom; var map = MapView.Active.Map; await QueuedTask.Run(() => { var layer = LayerFactory.Instance.CreateLayer<FeatureLayer>(layerParams, map); });
System.Object
ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
ArcGIS.Desktop.Core.Item
ArcGIS.Desktop.Catalog.ServerConnectionProjectItem
Target Platforms: Windows 11, Windows 10