0

Using these resources:

http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/createmapsddraft.htm

https://community.esri.com/thread/139716

I have a script that is able to successfully publish my MXD to a service. The only issue is when I publish the service all feature access (create, delete, query, sync, update) is enabled. What I would like is only to have Query and Update enabled like shown in the screenshot below:

enter image description here

My code for that section is below, I can paste the entire code but the problem is entirely with this section (when I comment it out everything publishes fine but with all the feature access operations allowed)

# Turn on feature access capabilities
configProps = doc.getElementsByTagName('Info')[0]
propArray = configProps.firstChild
propSets = propArray.childNodes
for propSet in propSets:
    keyValues = propSet.childNodes
    for keyValue in keyValues:
        if keyValue.tagName == 'Key':
            if keyValue.firstChild.data == "WebCapabilities":
                keyValue.nextSibling.firstChild.data = "Query,Update,Uploads,Editing"

I think it is probably just a syntax issue but I am not sure.

Has anyone done anything like this and if so what was your solution?


I found this page https://community.esri.com/thread/181211 which says that the proper index is [7] instead of [0] so I updated my code to this

configProps = doc.getElementsByTagName('Info')[7]
propArray = configProps.firstChild
propSets = propArray.childNodes
for propSet in propSets:
    keyValues = propSet.childNodes
    for keyValue in keyValues:
        if keyValue.tagName == 'Key':
            if keyValue.firstChild.data == "WebCapabilities":
                keyValue.nextSibling.firstChild.data = "Query,Update,Editing"

Now the script does not error out when it publishes but it is still publishing with CREATE and DELETE still enabled.

  • 2
    How is this question to broad, it has a very narrow scope, specifically how to publish a service with those options enabled. It also has a perfectly good answer. I have no idea how this can be classified as too broad. – ed.hank Jan 8 '18 at 21:29
  • Thanks for leaving this up. No idea why this question was closed. It honestly shouldn't have been. – user125266 Oct 8 '18 at 17:53
  • @Steve - Thank you! I totally agree, I never could understand how it was too broad. – ed.hank Oct 8 '18 at 18:46
1

After doing much research I figured this out. The code snippet I posted needs to be totally replaced with this:

# Get all the value tags.
values = doc.getElementsByTagName('Value')
for value in values:
    if value.hasChildNodes():
    # Change the default WebCapabilities from 'Query,Create,Update,Delete,Uploads,Editing' to just 'Query'.
        if value.firstChild.data == 'Query,Create,Update,Delete,Uploads,Editing':
            value.firstChild.data = 'Query,Update,Uploads,Editing'

This will allow do Updating of existing data, but it will not allow the user to create nor delete any existing data. The parameters 'Query,Create,Update,Delete,Uploads,Editing' can be swapped out with the exact parameters you wish.

Normally I would just delete this question, but I think others may benefit from it as publishing services with specific parameters is something we do often at my shop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.