To modify the sddraft file and enable feature capability, the following code worked for me
# Read the sddraft xml.
doc = DOM.parse(sddraft_output_filename)
# Find all elements named TypeName. This is where the server object extension
# (SOE) names are defined.
typeNames = doc.getElementsByTagName('TypeName')
for typeName in typeNames:
# Get the TypeName we want to enable.
if typeName.firstChild.data == "FeatureServer":
extension = typeName.parentNode
for extElement in extension.childNodes:
# Enable Feature Access.
if extElement.tagName == 'Enabled':
extElement.firstChild.data = 'true'
if extElement.tagName == 'Info':
for propArray in extElement.childNodes:
if propArray.tagName == 'PropertyArray':
for propSet in propArray.childNodes:
for prop1 in propSet.childNodes:
if prop1.tagName == "Key":
if prop1.firstChild.data == 'WebCapabilities':
# Turn on feature access capabilities
if prop1.nextSibling.hasChildNodes():
prop1.nextSibling.firstChild.data = "Map,Query,Data"
else:
txt = doc.createTextNode("Map,Query,Data")
prop1.nextSibling.appendChild(txt)
# Output to a new sddraft.
sddraft_mod_xml = 'sddraft_output_mod_xml' + '.sddraft'
sddraft_mod_xml_file = os.path.join(draftsOutputDir, sddraft_mod_xml)
f = open(sddraft_mod_xml_file, 'w')
doc.writexml(f)
f.close()
Abdur Rahman
GIS Developer