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.

3
  • 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
    Commented Jan 8, 2018 at 21:29
  • I'm not sure whether your comment here reached my inbox 18 months ago but if your comment had included a ping (@ followed by my username) then it certainly should have. I've just reviewed my close vote on this question and I am surprised that I voted that way. I wonder whether I was looking at two questions in different browser tabs and accidentally clicked Too Broad on the wrong one. Because I cannot now justify why I close voted this question I apologize for having done so, and am glad that @Fezter rectified my mistake and re-opened it albeit much later.
    – PolyGeo
    Commented Jul 30, 2019 at 0:56
  • Curiously, 3 other users agreed with my close vote so up to four of us must have seen something we thought amiss with it at that time. If you ever feel that I, any other moderator and/or the community has closed one of your questions for a reason that you cannot understand, then the way to try and remedy that, if a comment ping has not worked, is to ask a question at Geographic Information Systems Meta.
    – PolyGeo
    Commented Jul 30, 2019 at 1:00

1 Answer 1

2

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 and acknowledge you have read our privacy policy.

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