0

Publishing map service the normal way is done here using arcgis desktop.

But I decided to do it with python so I can automate the process or something like that but first off I need to edit some of the info according to this, you would create the SD file before publishing. Due to the 0 rep I can't post more then two links but normal publishing normal publishing

and using arcpy

using arcpy.

As you can see I highlighted the description according to the image does it means it is searching for the Item Description.

Is the the right way of doing it

# find the Item Information Description element 
Capability= doc.getElementsByTagName('Capabilities')
for item in Capability:
    if item.parentNode.tagName == 'FeatureAccess':
       #How do i check this check box?
    else:
1

The tag you want to be looking for is 'TypeName'.

you can access it like this:

import xml.dom.minidom as dom

def feature_server_toggle(doc, status):
    type_names = doc.getElementsByTagName('TypeName')
    for type_name in type_names:
        if type_name.firstChild.data == "FeatureServer" and status.lower() == 'on':
            type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "true"
        if type_name.firstChild.data == "FeatureServer" and status.lower() == 'off':
            type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "false"

sddraft = <path/to/sddraft>
output = <path/to/output>
doc = dom.parse(sddraft)

with open(output, 'w+') as xml:
    feature_server_toggle(doc, 'on')
    doc.writexml(xml)

Or you could alter the function to allow it to enable or disable any capability like so:

import xml.dom.minidom as dom

def capability_toggle(doc, server_type, status):
    type_names = doc.getElementsByTagName('TypeName')
    for type_name in type_names:
        if type_name.firstChild.data == "{}".format(server_type) and status.lower() == 'on':
            type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "true"
        if type_name.firstChild.data == "{}".format(server_type) and status.lower() == 'off':
            type_name.parentNode.getElementsByTagName("Enabled")[0].firstChild.data = "false"

sddraft = <path/to/sddraft>
output = <path/to/output>
doc = dom.parse(sddraft)

with open(output, 'w+') as xml:
    capability_toggle(doc, 'FeatureServer', 'on')
    capability_toggle(doc, 'KmlServer', 'off')
    doc.writexml(xml)

Here is a list of valid values to use for server_type:

  • ‘KmlServer’
  • ‘FeatureServer’
  • ‘MapServer’
  • ‘WCSServer’
  • ‘WMSServer’
  • ‘WFSServer’
  • ‘SchematicsServer’
  • ‘MobileServer’
  • ‘NAServer’
|improve this answer|||||
0

Okay this is something new and the simnple solution to this is save a Service Draft file and open up with a text editor. Next you are able to search for the capabilities you want to change for example the Feature Access which I wanted was called the

Example

|improve this answer|||||

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.