I am in process of updating ArcSDE server from 9.31 10 10.2. There are lots of MSD files that uses old SDE server connection and need to be updated with correct path and Dataset Names. I tried using IMSDHelper to update connection string but I am wondering how to update other parameter's for MSD to republish it.
You said that you are updating ArcSDE, so your data model should remain the same. Are you saying "upgrade"? In fact, with a true upgrade the database name and locations of each feature class and table should all remain the same. If that is the case, then your MSD should connect just fine to the database after the upgrade. If you have actually created a new geodatabase, then hopefully the data is still structured the same. What I would suggest is to open the MSD (or the MXD that was used initially to produce the MSD) such that the layer data sources are broken (e.g., red exclamation points). This can be done by opening the MSD when the computer is not connected to the network or by stopping your old ArcSDE instance temporarily. The goal is to get the MSD open so the layers and tables in the TOC are all broken. Once you have your new SDE connection set up in ArcCatalog, right click on one of your broken layers and pick Repair Data... in order to re-point to the same object class in your upgraded database. Once you repair one layer, everything else should repair automatically. Save your MSD from there, or if you've done this in an MXD, then re-generate a new MSD. Another option, which I've found to be tedious and cumbersome, is to use the Repair MXD Data Connection tool (which works on MSDs too). Here is a good article that covers the process within Step 1, albeit from Geocortex.
Starting at ArcGIS 10.1, Map Server Definition (.msd) files have been replaced with Service Definition Draft (.sddraft) and Service Definition (.sd) files. Every MXD document from which you were able to create an MSD in 9.3.1, you should be able to be able to convert into a Service Definition. You can relatively easily use Python to programmatically change your 9.3.1 MXDs and publish them to 10.2.
Updating your mxds (use from a machine running ArcGIS Desktop 10.2):
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project_default.mxd") mxd.findAndReplaceWorkspacePaths(r"C:\Project\Connection to Default.sde", r"C:\Project\Connection to Version1.sde") mxd.saveACopy(r"C:\Project\Project_V1.mxd") del mxd
Publishing your mxds (also run from a machine running 10.2):
import arcpy
# define local variables wrkspc = 'C:/Project/' mapDoc = arcpy.mapping.MapDocument(wrkspc + 'Project_default.mxd') con = r'GIS Servers\arcgis on MyServer_6080 (admin).ags' service = 'Default' sddraft = wrkspc + service + '.sddraft' sd = wrkspc + service + '.sd'
# create service definition draft arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER', con, True, None) # analyze the service definition draft analysis = arcpy.mapping.AnalyzeForSD(sddraft)
# stage and upload the service if the sddraft analysis did not contain errors if analysis['errors'] == {}: # Execute StageService arcpy.StageService_server(sddraft, sd) # Execute UploadServiceDefinition arcpy.UploadServiceDefinition_server(sd, con) else: # if the sddraft analysis contained errors, display them print analysis['errors']