Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers 3

right click the map service document and look for the properties..

share|improve this answer
    
Sorry, should have specified that I want to do it programmatically (through arcpy or similar). –  Ron Warholic Dec 19 '11 at 19:55
add comment

Have a look at IMapServerObjects2

You can get ArcServer map and layer properties from that.

http://resources.esri.com/help/9.3/arcgisdesktop/arcobjects/esriCarto/IMapServerObjects2.htm

share|improve this answer
    
Just a note, this is ArcObjects not arcpy. However it is possible to access ArcObjects from Python. –  blah238 Dec 19 '11 at 20:34
    
Right, the question was specified as "arcpy or something else". Anyway, IMapServer3.DocumentInfo may be closer to what you need. –  ericoneal Dec 19 '11 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. –  Ron Warholic Dec 19 '11 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 Dec 20 '11 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 ;) –  Ron Warholic Dec 22 '11 at 0:35
add comment

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

share|improve this answer
    
this answer using AGSSOM could help as well. –  geojeff Feb 22 '12 at 19:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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