<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Modifying Service Definition Draft file to enable WMS capabilities? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/modifying-service-definition-draft-file-to-enable/m-p/1078625#M61732</link>
    <description>&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.CreateImageSDDraft(rasterimage, output_draft, service, 'FROM_CONNECTION_FILE', con, True, None, "netCDF test", "test,auto")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how i enable WMS :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is how i create a new draft file for storing updated&amp;nbsp; properties. and here is the problem. The info from previous file is lost and so i see a black image:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;new_draft=r"C:/Users/fk/arcgis/image1.sddraft"
f = open(new_draft, 'w')     
doc.writexml( f )     
f.close()   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jul 2021 12:21:32 GMT</pubDate>
    <dc:creator>RehanChaudhary</dc:creator>
    <dc:date>2021-07-14T12:21:32Z</dc:date>
    <item>
      <title>Modifying Service Definition Draft file to enable WMS capabilities?</title>
      <link>https://community.esri.com/t5/python-questions/modifying-service-definition-draft-file-to-enable/m-p/1078625#M61732</link>
      <description>&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.CreateImageSDDraft(rasterimage, output_draft, service, 'FROM_CONNECTION_FILE', con, True, None, "netCDF test", "test,auto")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is how i enable WMS :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is how i create a new draft file for storing updated&amp;nbsp; properties. and here is the problem. The info from previous file is lost and so i see a black image:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;new_draft=r"C:/Users/fk/arcgis/image1.sddraft"
f = open(new_draft, 'w')     
doc.writexml( f )     
f.close()   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 12:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modifying-service-definition-draft-file-to-enable/m-p/1078625#M61732</guid>
      <dc:creator>RehanChaudhary</dc:creator>
      <dc:date>2021-07-14T12:21:32Z</dc:date>
    </item>
  </channel>
</rss>

