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.
}
});
}