GetDefinitions() returns nothing for Map Service Geodatabase

888
2
01-27-2021 08:54 AM
DavidLaMartina
New Contributor III

I am instantiating a Geodatabase using the ServiceConnectionProperties constructor, which contains the url of a map service. If I call GetDefinitions() (for either TableDefinition or FeatureClassDefinition), the method returns an empty list.

However, I am able to access specific tables and their definitions using OpenDataset() and GetDefinition().

Through tinkering in Visual Studio's immediate window, I have found that if I call OpenDataset() on a specific table, then THAT table's definition will appear in the results of GetDefinitions(). For example, I have a map service with 19 feature classes. If I call OpenDataset() on 8 of those feature classes, then those 8 - and only those 8 - will appear in the results of GetDefinitions().

I was hoping to use the workflow described in other threads related to fetching data from map services: I have a string that likely matches an alias of one of the map service's feature classes or tables. I call GetDefinitions() to get all of the table definitions, and then call GetAlias() for each of those definitions, so that I can match the alias. This is still technically possible with a workaround (call GetDefinition("0"), GetDefinition("1"), etc. until I either find a match or until that causes an Exception), but it'd be nice to actually get all of the definitions off the bat.

Is this a bug? Something potentially wrong with the way the Map Service is set up? I would assume the latter isn't the case, as I've been testing using the ESRI World_Imagery service.

Edit - here is the Map Service I'm using to test: https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer

0 Kudos
2 Replies
KirkKuykendall1
Occasional Contributor III

If you can provide a publicly accessible url, people would find it easier to reproduce the problem.

KirkKuykendall1
Occasional Contributor III

I think the mapservice needs to be published with "feature access" enabled.

When that is done, there should be a url with FeatureServer in it.

The code below works for me with Naperville sample data:

private void ListDefs()
{
    var url = @"https://sampleserver7.arcgisonline.com/arcgis/rest/services/UtilityNetwork/NapervilleElectric/FeatureServer";
    QueuedTask.Run(() =>
    {
        var scp = new ServiceConnectionProperties(new Uri(url));
        var geodb = new Geodatabase(scp);
        var defs = geodb.GetDefinitions<FeatureClassDefinition>();
        foreach (var def in defs)
            Debug.Print($"{def.GetName()} {def.GetAliasName()}");
    });
}