AnsweredAssumed Answered

Change Title in sdddraft file when overwriting service

Question asked by lukas.wuersch_CDE on Jun 3, 2020

Hi there

 

When programmatically publishing Map Image Services to ArcGIS Enterprise Portal, it is possible to define the service's title (the one which will be displayed in the item’s portal page after publishing) by modifying the .sddraft file. Please find an example below:

 

[...]

layer_sharing_draft = map.getWebLayerSharingDraft(target_server_type, "MAP_IMAGE", service_name)
[...]
# Create Service Definition Draft file
layer_sharing_draft.exportToSDDraft(sddraft_file_path)

# Modify title in sddraft file
xml_sddraft = DOM.parse(sddraft_file_path)
title = xml_sddraft.getElementsByTagName('Title')
title[0].firstChild.data = service_title

# save as new sddraft file
with codecs.open(new_sddraft_path, "w", "utf-8") as f:
     xml_sddraft.writexml(writer=f, encoding="utf-8")
     f.close()
print(new_sddraft_path)
          
# stage service               
sd_file = arcpy.StageService_server(new_sddraft_path, sd_file_path) 
          
# upload service definition
arcpy.UploadServiceDefinition_server(sd_file, target_url)

 

While this works when creating services, it does not work when overwriting them. (when layer_sharing_draft.overwriteExistingService = True)

 

So when I overwrite an existing service, the title in the variable "service_title" is not shown as title in the service's portal page as I would expect.

 

The question is: Is it possible to edit the .sddraft file in such a way that the service title is changed when overwriting the service? Or is there another way to accomplish this?

Outcomes