Public Function New( _ ByVal serviceURL As Uri _ )
public ServiceConnectionProperties( Uri serviceURL )
Parameters
- serviceURL
- A valid path to a service URL.
ServiceConnectionProperties class.Public Function New( _ ByVal serviceURL As Uri _ )
public ServiceConnectionProperties( Uri serviceURL )
| Exception | Description |
|---|---|
| System.ArgumentNullException | serviceURL is null. |
{
//Url examples for (federated) feature services
//(by "ref" online):
var url =
@"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
}
});
}
{
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.
}
});
}
{
//Connect to the AGS service. Note: the connection will persist for the
//duration of the Pro session.
var serverUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services";
var username = "user1";
var password = "user1";
//at any point before creating a layer, first make a connection to the server
//if one has not been already established for the current session
var uri = new Uri(serverUrl);
var props = new ServiceConnectionProperties(uri)
{
User = username
};
//It is preferred that you use the Windows Credential Manager to store the password
//However, it can be set as clear text if you so choose
props.Password = password; //not recommended
//Establish a connection to the server at any point in time _before_
//creating a layer from a service on the server
//Note: Needs QueuedTask to run
var gdb = new Geodatabase(props);
gdb.Dispose();//you do not need the geodatabase object after you have connected.
//later in the session, as needed...create a layer from one of the services
//on the server
var serviceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure/MapServer";
var lc = new LayerCreationParams(new Uri(serviceUrl));
//Note: Needs QueuedTask to run
LayerFactory.Instance.CreateLayer<MapImageLayer>(lc, map);
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)