Select to view content in your preferred language

Need to Replace Out of Date Map Services in MXDs

2319
23
10-09-2013 02:58 PM
RandyKreuziger
Frequent Contributor
We just upgraded ArcGIS Server from 10.0 to 10.1.  Several users have MXDs that contain a map service that retired during the upgrade.  With the map service gone those MXDs take 10 to 30 minutes to open and another 5 minutes just to right click on the service in the TOC so it can be removed.

What is there in ArcPy to find and replace map services?  Let me know if this topic should go in another forum.

And, why the heck does ArcGIS Desktop spend so much time looking for a map service before giving up?
Tags (2)
0 Kudos
23 Replies
T__WayneWhitley
Honored Contributor
Hmmm, yes, now I see limitation in this method if you intend to use it with mxds, i.e. precisely identify which services are which.
I also see Michael's point; I don't use the map services locally in mxds either - and therein seems to lie the problem with identifying by name - the name property returns that as it is in the map TOC.  And that can be changed by the user (or whoever authored the mxd).

The only way I can really confidently identify (not really absolutely) with arcpy from the mxd perspective is to examine the contents of the layers within the map service - but then again I must know what a map service contains, and this doesn't always apply to map services obtained from elsewhere (someone else's server).  Searching metadata in this case may be your answer.

Otherwise, with this since I know precisely what is inside this 'composite' map service, I can rename in in the map TOC (in this case, the 2nd layer 'test', and I know what I have in my datastore and can logically ID it - yes, this is weak, but may be one of your optional work-arounds with arcpy
>>> mapLyrs = arcpy.mapping.ListLayers(mxd)

>>> mapLyrs

[<map layer u'MonroeGISData.DBO.BM_MileMarkers'>, <map group layer u'test'>, <map group layer u'Overview'>, <map layer u'MileMarker'>, <map layer u'Overseas Hwy - US 1'>, <map layer u'Base Map Annotation Water'>, <map group layer u'Base Map Annotation'>, <map layer u'Overview'>, <map layer u'Overview Island Level'>, <map layer u'Monroe County Boundary'>, <map layer u'Miami-Dade County Boundary'>, <map group layer u'MCPA'>, <map layer u'Roads'>, <map group layer u'Parcel ID Text'>, <map layer u'Default'>, <map layer u'Parcels'>, <map group layer u'Historic Areas'>, <map layer u'Historical Structures'>, <map layer u'Tavernier Historic District'>, <map layer u'Marsh Rabbit Buffer'>, <map layer u'Marsh Rabbit Habitat'>, <map layer u'Endangered Species'>, <map layer u'Habitat 2009'>, <map group layer u'Tier Overlay District'>, <map layer u'Tier Overlay District'>, <map layer u'Tier Labels'>, <map group layer u'FEMA'>, <map layer u'Flood hazard zone lines'>, <map layer u'DFIRM panel labels'>, <map layer u'Flood hazard zone text'>, <map layer u'CBRS'>, <map layer u'Zoning'>, <map layer u'FLUM (Draft)'>, <map layer u'2006 Orthophotography'>, <map layer u'2009 Orthophotography'>, <map layer u'2012 image catalog'>]



EDIT:
Interesting, I have never used this command before:

ListMapServices
Resource Center » Professional Library » Geoprocessing » The ArcPy site package » Mapping module » Functions » Managing Documents and Layers
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/ListMapServices/00s30000004s000000/
0 Kudos
MichaelVolz
Esteemed Contributor
ListMapServices appears to generate a list of all mapservices that are hosted on a specific server.  That does not appear to help this situation as you would want a different ListMapServices that would list all the mapservices found in an ArcMap document using their original name and not the name that appears in the TOC.
0 Kudos
T__WayneWhitley
Honored Contributor
Yes I see the dilemma....unfortunate.  But is it at least an option to examine the 'sub-layers' inside the map service and identify it in that fashion?  I admit, it is difficult.

That list command is being deprecated anyway - at 10.1 there is a lot more to explore with the Administrator API:

Scripting with the ArcGIS Server Administrator API
Services » ArcGIS for Server (Windows) » Administering ArcGIS for Server » Scripting ArcGIS Server administration
http://resources.arcgis.com/en/help/main/10.1/index.html#//0154000005r1000000

Maybe there is a solution for this thread outside of arcpy?...shot in the dark, but if the new map service is named the same on a new server you could edit your hosts file to redirect, not much of a workaround but could get you out of this pinch.


Wayne
0 Kudos
MichaelVolz
Esteemed Contributor
I have just detected another problem with out-of-date services that you can test yourself as well.  Some GIS users added ArcIMS services from public sites such as USGS which I believe required credentials.  At this point in time, the service has been retired.  This causes my python script to hang on these mxds for about 20 minutes (very problematic if my batch of mxds is over 500 files).

To try to solve this problem, I opened this file in ArcMap and deleted this service and then saved the mxd.  When I re-opened the saved mxd, I was still getting a dialog box asking for the ArcIMS service credentials even though I deleted this service.  I then repaired the mxd with MxdDoctor which finally solved the problem.

Why would ArcMap hold on to any part of the retired ArcIMS service if I deleted it from the mxd and subsequently saved the mxd without any reference to this retired ArcIMS service?
0 Kudos