ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Core.Data Namespace / Geodatabase Class / Geodatabase Constructor / Geodatabase Constructor(ServiceConnectionProperties)
A valid ServiceConnectionProperties object which has the URI to the feature service set. In case of feature services hosted on ArcGIS Server which is not federated with ArcGIS Portal, the username and password properties are also expected to be set.
Example

In This Topic
    Geodatabase Constructor(ServiceConnectionProperties)
    In This Topic
    Opens a web geodatabase given a serviceConnectionProperties to a valid feature service location. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    serviceConnectionProperties
    A valid ServiceConnectionProperties object which has the URI to the feature service set. In case of feature services hosted on ArcGIS Server which is not federated with ArcGIS Portal, the username and password properties are also expected to be set.
    Exceptions
    ExceptionDescription
    The serviceConnectionProperties to the feature service are invalid or if the feature service could not be opened.
    This object must be created within the lambda or delegate passed to QueuedTask.Run, or on a compatible STA thread.
    Example
    Connecting to a Feature Service using a URL
    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
            }
        });
    }
    Connecting to Different Types of Feature Services
    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.
            }
        });
    
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also