Select to view content in your preferred language

Need to Replace Out of Date Map Services in MXDs

2314
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
JeffBarrette
Esri Regular Contributor
Document versioning needs to be added.  Please add this to the ideas site.

The above idea is good but it only tells you what version of ArcGIS is installed, not what version the MXD is.  The text element class is the most useful for this:  text.textAngle = 10.2, text.clone=10.1.

Jeff
0 Kudos
RandyKreuziger
Frequent Contributor
Document versioning needs to be added.  Please add this to the ideas site.


There are at least 3 relevant proposals in the ideas site. Time to vote 🙂

https://c.na9.visual.force.com/apex/ideaView?id=087E00000004qGSIAY

https://c.na9.visual.force.com/apex/ideaView?id=087E00000004b98IAA

https://c.na9.visual.force.com/apex/ideaView?id=08730000000c1LUAAY
0 Kudos
MichaelVolz
Esteemed Contributor
In regards to ArcMap maintenance it would be good if the user had the option of either embedding the SDE credentials in the mxd or using .sde files outside the mxd to create the necessary SDE connections.  This could mean the difference between updating a few .sde files as opposed to thousands or more SDE connections inside mxd files.

Please vote at the following location:

http://ideas.arcgis.com/ideaView?id=087E00000004wTD&returnUrl=%2Fapex%2FideaList%3Fc%3D09a300000004x...
0 Kudos
RandyKreuziger
Frequent Contributor
Just when I thought I had it :mad:

With several users dead in the water we decided to recreate the missing Map Service so users could get into their MXDs while I work on the script.  That's created a new issue.  In my script I'm removing all broken Map Services, but now that a dummy Map Service is available there's no broken map services to delete.  So I need to delete a Map Service based on its name but I can't figure out how to find the orginal Map Service name.

Both lyr.name and lyr.longName display the name from ArcMap's table of contents.  Several users have renamed the Map Service name after adding it to the map's TOC, so I'm unable to test for the original name.

None of the service properties for a Map Service give the source map service name.
print lyr.serviceProperties

{u'UserName': u'',
u'ServiceType':
u'MapServer',
u'Connectionfile': u'C:\\Users\\xxxx\\AppData\\Roaming\\ESRI\\Desktop10.0\\ArcCatalog\\arcgis on gisolymap01.ags',
u'URL': u'http://gisolymap01/arcgis/services',
u'Server': u'',
u'Allowinsecuretokenurl': u'0',
u'Anonymous': u'-1'}

Any ideas?
0 Kudos
MichaelVolz
Esteemed Contributor
According to documentation for layer in v10.1, the URL should get you the name of the service as this is part of the URL, unless it is through a LAN.  Are you working on a LAN when processing this script?

The URL for this documentation is:

http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000008000000

Go to the area Keys for a web service dictionary.

Please let me know if this helps.

My organization has decided to avoid using services in mxds (especially outside services) as you never know when they will be retired which would cause broken links as you are experiencing.
0 Kudos
RandyKreuziger
Frequent Contributor
Michael,
  I'm gettting a URL back but it doesn't list the mapservice or the folder.  Here is what I get: http://aimsw.xxx.wa.lcl/arcgis/services

According to the documentation the URL will be null if through a LAN

[INDENT]URL �??Property displaying the URL to the service. If the connection to ArcGIS for Server is through a local area network (LAN), this value will be null[/INDENT]

Could it be that ESRI is not making the map service name available through arcpy?
0 Kudos
MichaelVolz
Esteemed Contributor
Randy:

I would log an incident with ESRI at this point because their documentation is misleading at best.  If you are on a LAN, then you should have received a Null value but you got the URL without the service name.  If you are not on the LAN, then you should have received the URL including the service name but you did not get the service name in the URL.  The documentation that I referred to is for arcpy's mapping module which should be exposed in python.
0 Kudos
T__WayneWhitley
Honored Contributor
Just to add to what Michael said at post #15:
I think the service name is simply fetched with the name property...but 1st you have to make sure it is service - I think at 10.1, more direct access was provided for that property, meaning you don't have to get it from the serviceProperties dictionary; it is simply isServiceLayer (and of course, if true then get the name).

This is a little testing on one of my 10.0 map services, and I think you'll get the picture:
>>> if mapServiceGrp0.supports("SERVICEPROPERTIES"):
...     for i, j in mapServiceGrp0.serviceProperties.iteritems():
...         print "{0}:  {1}".format(i, j)
...         
UserName:  
ServiceType:  MapServer
Connectionfile:  C:\Documents and Settings\whitley-wayne\Application Data\ESRI\Desktop10.0\ArcCatalog\mc-gisappserver (admin).ags
URL:  
Managerurl:  http://mc-gisapperver/arcgis/services
Server:  mc-gisappserver
Allowinsecuretokenurl:  0


I could have looked up the ServiceType key directly and identified it as a MapServer...but I need the name, so this:
>>> # This 1st one is an SDE 'service' - have to distinguish between SDE and other supporting service layer...
>>> mm = mapLyrs[0]
>>> mm.name
u'MonroeGISData.DBO.BM_MileMarkers'

>>> # so I could have queried a bit further to get type 'SDE' above...but with DBO in the name I already know.
>>> # This 2nd layer is the map service from 1st code section above - I need the name.
>>> mapServiceGrp0 = mapLyrs[1]
>>> mapServiceGrp0.name
u'MonroeCountySDE_Environmental_Layout'


It should be that simple -- just with 10.1 and above you can readily identify whether a service (and serviceProperties yields more details about that service).

Hope that helps,
Wayne

PS- If it shows better what I mean about 'SDE service' vs for example a 'Map Service', see this where I use an identical technique looping through the serviceProperties dictionary:
http://forums.arcgis.com/threads/94600-PLEASE-HELP!-Features-do-not-get-updated-in-Geoprocessing-Ser...
0 Kudos
RandyKreuziger
Frequent Contributor

This is a little testing on one of my 10.0 map services, and I think you'll get the picture: 
>>> if mapServiceGrp0.supports("SERVICEPROPERTIES"):
...     for i, j in mapServiceGrp0.serviceProperties.iteritems():
...         print "{0}:  {1}".format(i, j)
...         
UserName:  
ServiceType:  MapServer
Connectionfile:  C:\Documents and Settings\whitley-wayne\Application Data\ESRI\Desktop10.0\ArcCatalog\mc-gisappserver (admin).ags
URL:  
Managerurl:  http://mc-gisapperver/arcgis/services
Server:  mc-gisappserver
Allowinsecuretokenurl:  0



Wayne, using your code from the first example still returns a URL without the map service name. I need the folder /map service name. We do go through a balancer but that shouldn't be a problem.

UserName:  
ServiceType:  MapServer
Connectionfile:  C:\Users\kreuzrsk\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\arcgis on aimsw.xxx.wa.ags
URL:  http://aimsw.xxx.wa.lcl/arcgis/services
Server:  
Allowinsecuretokenurl:  0
Anonymous:  -1 
0 Kudos
MichaelVolz
Esteemed Contributor
Randy:

At the least it seems like this is a new idea for ideas.arcgis.com to access a mapservice name (not the TOC name that can change) with python scripting as it does not seem possible at this point.
0 Kudos