Select to view content in your preferred language

Update map service server paths in MXD

970
4
10-02-2013 08:23 AM
LeeBrannon
Regular Contributor
I have an mxd (10.1) with roughly 15 map services added in as layers in the map. These map services are from our in-house ArcGIS Server (10.1).

I need to update the server path on each map service link in the mxd so they will display on the map - this is because we lost a server port and need to use our other server port (both ports are (were) setup on our ArcGIS Server to allow map service consumption by clients). This seemed like a good use of arcpy.mapping scripting so I tried to use

mxd.findAndReplaceWorkspacePaths(OLDfolderPath, NEWfolderPath)

to accomplish this task. No luck. No error returned, just no update to the map service server paths in the mxd. Should the function above work in this situation or is there another function I should be using to automate this task?

** See attached Python script

Thanks,
Lee
Tags (2)
0 Kudos
4 Replies
SchoppMatthieu
Deactivated User
I'm pretty sure you can not change mapservice datasource with arcpy unfortunately. I can't find a specific post or documentation that explicitly says it but I remember I voted for someone suggesting the idea on http://ideas.arcgis.com

You can not use arcpy.mapping replaceWorkspaces, ArcGIS Server is not part of the "replaceable" workspace. Here

A mapservice can be list as a layer in a map document using : for layer in arcpy.mapping.ListLayers()
Then it has the property : layer.isServiceLayer = True
So you can access to its : layer.serviceProperties with the information about ArcGIS Server connection properties.

However, serviceProperties are read only... 😞


If I'm right, this limitation should definitively appear and here, here

Dear Esri, can we have further information about it ?
0 Kudos
LeeBrannon
Regular Contributor
It seems you're correct. 

The Help references you've included do not explicitly say anything regarding exceptions being ArcGIS Server map service paths, which would be helpful if they did explicitly mention it, but those references do seem to list what constitutes a viable workspace for function input and map service is not to be found in the list.

I appreciate the reply!  Thanks.

If there is an automated method that will work for this, then its development is probably going to require more time than I can spare right now.

Lee
0 Kudos
JeffBarrette
Esri Regular Contributor
Have you tried creating a layer file that references the service?  Then try using arcpy.mapping UpdateLayer or AddLayer followed by RemoveLayer.

Jeff
0 Kudos
LeeBrannon
Regular Contributor
Jeff

I did happen to see those options (UpateLayer/AddLayer) after my last post, but I have not yet tried to do it that way.  Seems like it would work, but I would just have to manually reload each map service, from the functioning server connection, into an mxd and save each as a layer file (which should be scriptable with SaveToLayerFile_management, maybe) , then try UpdateLayer with the new layer files.

Thanks for getting my mind back on that...I'll try it out and re-post about it.

Lee
0 Kudos