Modifying Service Definition Draft file to enable WMS capabilities?

464
0
07-14-2021 05:21 AM
RehanChaudhary
Occasional Contributor

I am trying to automate the process of publishing WMS services directly from a raster file without using a map document or project file. I am able to publish an imagery layer or a map image layer but when i try to modify the image draft file to enable the WMS or WFS capabilities and create a new draft file it displays a black image for the image layer and the WMS. Probably because the information from previous file is not copied to the new file and i am not referencing the data in my workflow but rather copying it to the server. How can i enable WMS on my layer? Here is how i implement the image draft file:

 

arcpy.CreateImageSDDraft(rasterimage, output_draft, service, 'FROM_CONNECTION_FILE', con, True, None, "netCDF test", "test,auto")

 

Here is how i enable WMS :

 

doc=DOM.parse(output_draft)
typeNames = doc.getElementsByTagName('TypeName')
for typeName in typeNames:
    # Get the TypeName whose properties we want to modify.
    if typeName.firstChild.data == "WMSServer":
        extension = typeName.parentNode
        for extElement in extension.childNodes:
            # Enabled SOE.
            if extElement.tagName == 'Enabled':
                extElement.firstChild.data = 'true'

 

 Here is how i create a new draft file for storing updated  properties. and here is the problem. The info from previous file is lost and so i see a black image:

 

 

new_draft=r"C:/Users/fk/arcgis/image1.sddraft"
f = open(new_draft, 'w')     
doc.writexml( f )     
f.close()   

 

0 Kudos
0 Replies