I have several map services published to ArcGIS Server 10.0 SP2 and I have layer metadata files exported to HTML that I want to link to the layers in the map service.

Currently the metadata HTML files are named based on the data source (eg 'Zip_Code_Poly.htm') but I need to correlate the layer name/ID from the map service to that file. I was thinking that the easiest way to do it would be to run an arcpy script to get all the layer data sources.

I've run into an issue though that the client (this is a web app) needs to look up these HTML files by service name and layer name/ID but without hard coding a mapping from service -> MXD I can't figure out what map document to use in arcpy.

Is there a way using arcpy or something else that I can look at a published map service and get the map document it was created from?

  • right click the map service document and look for the properties.. Commented Dec 19, 2011 at 19:53
  • Sorry, should have specified that I want to do it programmatically (through arcpy or similar). Commented Dec 19, 2011 at 19:55

2 Answers 2


Have a look at IMapServerObjects2

You can get ArcServer map and layer properties from that.


  • Just a note, this is ArcObjects not arcpy. However it is possible to access ArcObjects from Python.
    – blah238
    Commented Dec 19, 2011 at 20:34
  • Right, the question was specified as "arcpy or something else". Anyway, IMapServer3.DocumentInfo may be closer to what you need.
    – ericoneal
    Commented Dec 19, 2011 at 20:35
  • Is there a specific method of IMapServerObjects2 I should be looking for? I can't find a property of it or IMap that would give me the map document path/filename. Commented Dec 19, 2011 at 21:08
  • 1
    Some would argue ArcPy is ArcObjects as all it seems to be is a wrapper around the same COM objects ;)
    – Hairy
    Commented Dec 20, 2011 at 8:49
  • So I looked around at the ArcObjects documentation and failed to find what I'm looking for. In essence, I need to be able to talk to a published map service (not a map document) and ask it: What document (MXD/MSD) created you? I'm pretty sure that there isn't such a beast yet but I would enjoy being proven wrong ;) Commented Dec 22, 2011 at 0:35

I don't quite understand the question, but you can use xml.dom.minidom to read the FilePath from the map service cfg file (if you can talk to the published service from the server machine itself). Something like:

confRoot = r"C:\Program Files (x86)\ArcGIS\Server10.0\server\user\cfg\MapServiceFolder"
files = [x for x in os.listdir(confRoot) if x[-3:] == 'cfg']
for file in files:
    dom = parse(file)
    if dom.getElementsByTagName("FilePath")
    service_name = os.path.split(file)[1].split('.')[0]
    mapfile = dom.getElementsByTagName("FilePath")[0].childNodes[0].nodeValue

Dirty, but this would at least enable you to make a txt file or something on the server your web app can access. Running services have an .sts file alongside the .cfg

  • this answer using AGSSOM could help as well.
    – geojeff
    Commented Feb 22, 2012 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.