I have written a Python script tool that publishes map services for my organization. It works great, except that I am trying to publish read-only feature services with the "Sync" capability for offline mobile use. After following examples from Esri/other forums, I set the capabilities in my script by parsing the service definition draft as an xml document, as shown here:
# turn on feature access if service is editable
if service.endswith("Editable") or service.endswith("Redlining") or allowSync:
featAccessSettings = doc.getElementsByTagName("TypeName")
for featAccessSetting in featAccessSettings:
if featAccessSetting.firstChild.data == "FeatureServer":
featAccessSetting.parentNode.getElementsByTagName("Enabled").firstChild.data = "true"
configProps = doc.getElementsByTagName("Info")
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":
if (service.endswith("Editable")) or (service.endswith("Redlining")):
keyValue.nextSibling.firstChild.data == "Query,Create,Update,Delete,Uploads,Editing"
keyValue.nextSibling.firstChild.data == "Query,Sync"
On the last line, to create a read-only feature service (according to this guide: Prepare data for offline use—Documentation | ArcGIS for Server ), I set the web capabilities to only Query and Sync, but when the tool completes running, the publish service still has full editing capabilities and Sync disabled. If I try to publish the service with the user interface inside ArcMap or ArcCatalog, the web capability settings come across correctly.
Is there another parameter that needs to be set programmatically, that I am missing here? I know the data has to be configured correctly to use Sync, but again, the data I've been testing with works fine when published though the UI.