Get Data Source for ArcGIS Map Service Layers

8049
15
Jump to solution
05-24-2016 03:47 PM
MeleKoneya
Regular Contributor

I am looking for some programmatic way to get the underlying data source used for a Map Service Layer.    We use mostly SDE layers, so I would like the Feature Class Name.    

I was able to do this with ArcObjects with C# .NET prior to 10.1 but I don't believe it can be done the same way due to the changes in ArcGIS Server architecture

Does anyone have any code examples of getting the layer sources?

I may end up using the MXD to compile data sources,  but would like to go against the map services directly if possible.

Thanks,

Mele

0 Kudos
1 Solution

Accepted Solutions
pheede-esri
Esri Contributor

Mele Koneya​: Adding to Jon's answer, you may want to take a look at this GitHub sample https://github.com/pheede/agsadmin-devsummit​. Specifically the GetServiceManifest method in https://github.com/pheede/agsadmin-devsummit/blob/master/ArcGISRESTAdmin/AGSClient.cs​ which uses the REST Admin API to do this.

View solution in original post

15 Replies
AdrianWelsh
MVP Notable Contributor

Mele,

Are you wanting to get the data source of your own company's Map Services? Or are you hoping to get the data source of any Map Service you find in ArcGIS Online?

0 Kudos
MeleKoneya
Regular Contributor

Adrian,

Thanks for the reply.

I am looking for the data source of our organization's map services that are hosted on our internal ArcGIS Server not those on AGOL.

Mele

0 Kudos
George_Thompson
Esri Frequent Contributor

Looks like you might be able to collect that information via ArcPy

Alphabetical list of arcpy.mapping functions—Help | ArcGIS for Desktop

Alphabetical list of arcpy.mapping classes—Help | ArcGIS for Desktop

Hope this helps gets you pointed in the correct direction.

Pythonpython snippets

--- George T.
BillDaigle
Occasional Contributor III

I think you'll need to go back to the source mxd.  I don't believe the originating source information is exposed via the service. 

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

If you have to go back to the mxd to do it programatically, you may want to see if there is something in this sample tool

http://www.arcgis.com/home/item.html?id=7d6f7b4548f64d7ca8ba5cf73b0d9932

Custom Toolbox providing a compact/detailed MXD description. Run in ArcMap/ArcCatalog.

The selected mxd file is analyzed and the result is saved in a txt report file. No need to open the Map Document.

I have done something similar, but I think I only grabbed the info for broken links. Python addin for data inventory and “broken-link” repair.​ so this tool might have more (I have not tested...just saw it as I was looking at the other samples)

JonathanQuinn
Esri Frequent Contributor

If you go to ArcGIS Server Manager, then click on the Service Workspaces button next to the Service name and the type of service, (it looks like a geodatabase/database icon), you can see the workspaces the data in the service resides in.  You can expand the workspace to see the individual feature classes in the service.  These are Rest calls, so take a look at the web traffic when traversing the Service Workspaces windows.

pheede-esri
Esri Contributor

Mele Koneya​: Adding to Jon's answer, you may want to take a look at this GitHub sample https://github.com/pheede/agsadmin-devsummit​. Specifically the GetServiceManifest method in https://github.com/pheede/agsadmin-devsummit/blob/master/ArcGISRESTAdmin/AGSClient.cs​ which uses the REST Admin API to do this.

View solution in original post

MeleKoneya
Regular Contributor

Thanks for the samples!   This looks like I was looking for.   I like that it is in C# too.   I will work with it this week.

0 Kudos
MeleKoneya
Regular Contributor

Philip, 

I am finally getting back to this,  but am not getting the information I want.   Below is the code that I am using.   Can you see what I am doing wrong?

Thanks,

Mele

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

AGSClient Client = new AGSClient("https://MyServer:6443/arcgis/admin", "User", "PWD");

 

Task<Dictionary<string, ArcGISRESTAdmin.Classes.ServiceReport[]>> taskServiceReports = Client.GetAllServiceReports();

Dictionary<string, ArcGISRESTAdmin.Classes.ServiceReport[]> dctServiceReports = taskServiceReports.Result;

foreach (KeyValuePair<string, ArcGISRESTAdmin.Classes.ServiceReport[]> kvp in dctServiceReports)

{

string theKey = kvp.Key;

ArcGISRESTAdmin.Classes.ServiceReport[] serviceReports = kvp.Value;

for (int x = 0; x < serviceReports.Length; x++)

{

string serviceName = serviceReports.serviceName;

string configuredStatus = serviceReports.status.configuredState.ToString();

Task<ServiceManifest> manifest = Client.GetServiceManifest(serviceReports, "");

}

}

}

}

}

0 Kudos