public async Task OpenFeatureServiceUsingUrl(string url) { //Url examples for (federated) feature services //(by "ref" online): //https://sampleserver6.arcgisonline.com/arcgis/rest/services/LocalGovernment/Recreation/FeatureServer //(federated by ref on portal) //https://portal.example.com/server/rest/services/FeatureServiceName/FeatureServer"); //(federated by value - Hosted - on portal) //https://portal.example.com/server/rest/services/Hosted/FeatureServiceName/FeatureServer"); await QueuedTask.Run(() => { var uri = new Uri(url, UriKind.Absolute); using (var fs_db = new ArcGIS.Core.Data.Geodatabase(new ServiceConnectionProperties(uri))) { //Use the geodatabase } }); }
public async void ConnectToDifferentTypesOfFeatureService() { await QueuedTask.Run(() => { Uri nonFederatedServerURL = new Uri( "https://arcgis.server.example.com:6443/arcgis/rest/services/FeatureServiceName/FeatureServer"); // Note that for non-federated ArcGIS Server hosted feature services, // the username and password have to be specified always. ServiceConnectionProperties nonFederatedArcGISServer = new ServiceConnectionProperties(nonFederatedServerURL) { User = "serverUser", Password = "serverPassword" }; using (Geodatabase nonFederatedServerFeatureService = new Geodatabase(nonFederatedArcGISServer)) { // Use the feature service geodatabase. } //Hosted (or published "by value") Uri federatedServerURL = new Uri( "http://federated.with.portal.example.com/server/rest/services/Hosted/FeatureServiceName/FeatureServer"); //Published "by reference" //Uri federatedServerURL = new Uri( //"http://federated.with.portal.example.com/server/rest/services/FeatureServiceName/FeatureServer"); // Note that for feature services hosted on ArcGIS Server federated with // ArcGIS Portal, the username and password cannot be specified through the API. // Even if the username and password were specified, they will be disregarded. // Instead the Portal authorization has to be configured by adding the Portal to // ArcGIS Pro with the user with which the connection should be established. // To connect to a Portal from a CoreHost application, use the // ArcGIS.Core.SystemCore.ArcGISSignOn class to authenticate with the Portal. ServiceConnectionProperties federatedArcGISServer = new ServiceConnectionProperties(federatedServerURL); using (Geodatabase federatedServerFeatureService = new Geodatabase(federatedArcGISServer)) { // Use the feature service geodatabase. } Uri arcgisOnlineURL = new Uri( "http://services1.arcgis.com/47GG2ga246DGaLwa/arcgis/rest/services/FeatureServiceName/FeatureServer"); //or //https://sampleserver6.arcgisonline.com/arcgis/rest/services/LocalGovernment/Recreation/FeatureServer //etc // Similar to Federated Feature Services, note that for feature services // hosted on ArcGIS Online, the username and password cannot be specified through // the API. Even if the username and password were specified, they will be // disregarded. Instead the connection will be established based on the ArcGIS // Online user credentials used to login to ArcGIS Pro at startup. ServiceConnectionProperties arcGISOnline = new ServiceConnectionProperties(arcgisOnlineURL); using (Geodatabase arcGISOnlineFeatureService = new Geodatabase(arcGISOnline)) { // Use the feature service geodatabase. } }); }
Layer selectedLayer = MapView.Active.GetSelectedLayers()[0]; if (selectedLayer is FeatureLayer) { FeatureLayer featureLayer = selectedLayer as FeatureLayer; using (Table table = featureLayer.GetTable()) using (Datastore datastore = table.GetDatastore()) { ServiceConnectionProperties serviceConnectionProperties = datastore.GetConnector() as ServiceConnectionProperties; if (serviceConnectionProperties == null) return; Uri url = serviceConnectionProperties.URL; // Will be the URL to the Feature Service. string user = serviceConnectionProperties.User; // The username property will only be // populated for feature service hosted // on non-federated ArcGIS Server. string password = serviceConnectionProperties.Password; // Will always be empty. } }
System.Object
ArcGIS.Core.Data.Connector
ArcGIS.Core.Data.ServiceConnectionProperties
Target Platforms: Windows 11, Windows 10