I've been trying to figure out how to overwrite an existing service and I found the following code in ArcGIS Server Help:# Import system modules import arcpy from arcpy import env import xml.dom.minidom as DOM # Set environment settings env.workspace = "C:/data" # Set local variables inServiceDefinitionDraft = "myMapService.sddraft" outServiceDefinition = "myMapService.sd" newType = 'esriServiceDefinitionType_Replacement' xml = draftPath + in_sd_draft doc = DOM.parse(xml) descriptions = doc.getElementsByTagName('Type') for desc in descriptions: if desc.parentNode.tagName == 'SVCManifest': if desc.hasChildNodes(): desc.firstChild.data = newType outXml = xml f = open(outXml, 'w') doc.writexml( f ) f.close() # Execute StageService arcpy.StageService_server(inServiceDefinitionDraft, outServiceDefinition) # Set local variables inSdFile = outServiceDefinition inServer = "GIS Servers/myServerConnection" # Execute UploadServiceDefinition arcpy.UploadServiceDefinition_server(inSdFile, inServer)
Looks straight forward except for the line "xml = draftPath + in_sd_draft". Neither one of these variables (draftPath or in_sd_draft) are defined in the script and I don't know what they should be. Would it be c:/Data/myMapService.sddraft? Has anyone tried this script and gotten it to work?TIA