Select to view content in your preferred language

Programatically update a map service

554
2
03-30-2011 06:57 AM
TyroneLigon
Deactivated User
At this point, I just want to know if the following is possible by writing code (probably VB or even Python?):

   1. Open a map document and update the data source of several shapefiles
   2. Save the map document
   3. Stop and restart the map service associated with the map document
   4. Empty the map server cache so that the map document changes are propagated to the map service

BTW, Server 9.3 running on a Windows 2008 server
Tags (2)
0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor
At ArcGIS 10 there is the new arcpy.mapping module that allows you to repair/remap data sources very easily.  However, at 10 you still cannot use python to stop/start ArcGIS Server services.  It looks like there has been an enhancement request logged for this:

NIM063303: Provide functionality in ArcPy for managing map services.

Your best bet would be to use .NET.  I found some example code for stopping/starting services here:

http://help.arcgis.com/en/arcgisserver/10.0/help/arcgis_server_dotnet_help/index.html#//009300001655...
0 Kudos
TylerGarner
Deactivated User
I have achieved a similar task using python to change the data source and save the map, and then using AGSSOM to restart the map service.

In order to make this work, I had to write a batch file with the AGSSOM command line argument:

AGSSOM.exe -r USABasemapService

I then call the batch file from my python script after the map has been saved:
os.system('restartHeatMap.bat');
0 Kudos