Defining sharing options in the service definition draft

10-06-2021 06:04 AM
by Anonymous User
Not applicable


I want to publish a Map Image Service on ArcGIS Enterprise 10.8.1 with arcpy in ArcGIS Pro using arcpy.MapImageSharingDraft. By adapting the Modify SDDraft example 3 I parsed the Map Image Service sddraft to enable the WMS option.

The next stept would be staging and publishing but an error appears when staging: Error 00297 because WMS layer has to be shared with everyone. 

Is there a way to define the sharing option before staging the sddraft like setting an option in the sddraft itself? I wasn't able to find a line which adresses this issue. 



0 Kudos
3 Replies
Occasional Contributor III

I wrote some python code a while back to publish REST services to our ArcGIS server and as far as I could tell I could only secure the service after the publish (UploadServiceDefinition) was complete. This was fairly simple to do by sending  a series of requests via the Add Permissions REST API. First I  looped on the roles that I wanted to give access to  ({'principal': <role_name>, 'isAllowed': True}), then I sent a request to disable the public access ({'principal': 'esriEveryone', 'isAllowed': False})

I didn't enable WMS so maybe there is an issue there that I didn't have to deal with. I'm curious is somebody has a better way so that my "secure" endpoint doesn't have to be exposed publicly - even if it is only for a couple of seconds

0 Kudos
New Contributor

Hi, you can define the sharing option before staging the sddraft like setting an option in the sddraft itself. 

In the XML : SVCManifest > StagingSettings > PropertyArray and go to the PropertySetProperty node defined by the key Node name "PackageIsPublic": set true to the Value node

Best reg.

Esri Contributor

To expand on @jotaefe_1980 's instruction, here's an example of how to set the sharing settings in the .sddraft file:

# Read the .sddraft file
docs = DOM.parse(sddraft_output_filename)
key_list = docs.getElementsByTagName('Key')
value_list = docs.getElementsByTagName('Value')

# Change following to "true" to share
SharetoOrganization = "false"
SharetoEveryone = "true"
SharetoGroup = "false"
# If SharetoGroup is set to "true", uncomment line below and provide group IDs
GroupID = ""    # GroupID = "f07fab920d71339cb7b1291e3059b7a8, e0fb8fff410b1d7bae1992700567f54a"

# Each key has a corresponding value. In all the cases, value of key_list[i] is value_list[i].
for i in range(key_list.length):
    if key_list[i].firstChild.nodeValue == "PackageUnderMyOrg":
        value_list[i].firstChild.nodeValue = SharetoOrganization
    if key_list[i].firstChild.nodeValue == "PackageIsPublic":
        value_list[i].firstChild.nodeValue = SharetoEveryone
    if key_list[i].firstChild.nodeValue == "PackageShareGroups":
        value_list[i].firstChild.nodeValue = SharetoGroup
    if SharetoGroup == "true" and key_list[i].firstChild.nodeValue == "PackageGroupIDs":
        value_list[i].firstChild.nodeValue = GroupID

# Write to the .sddraft file
f = open(sddraft_output_filename, 'w')