<?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 Re: Publishing map service with WMS capability with arcpy in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1292458#M36042</link>
    <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My&amp;nbsp;service_admin_url was wrong. It works with the correct one:&lt;BR /&gt;&lt;BR /&gt;service_admin_url&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://xxx/server/admin/services/OGD/hochschule.MapServer" target="_blank"&gt;https://xxx/server/admin/services/OGD/hochschule.MapServer&lt;/A&gt;"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 24 May 2023 08:01:56 GMT</pubDate>
    <dc:creator>TWickiSLU</dc:creator>
    <dc:date>2023-05-24T08:01:56Z</dc:date>
    <item>
      <title>Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1085520#M30822</link>
      <description>&lt;P&gt;Hi, trying to use arcpy to publish and overwrite a service that has the WMS capability enabled.&amp;nbsp; Federated Server/Portal 10.8.1.&amp;nbsp; Code below isn't my full code, but I think I've reduced it down to what is relevant.&amp;nbsp; The problem is that when the final line runs that stages the service, it does an analyse and throws and error:&lt;/P&gt;&lt;P&gt;ERROR 001272: Analyzer errors were encountered ([{"code":"00297","message":"WMS layers must be shared with everyone","object":"MyServiceName"}]).&lt;/P&gt;&lt;P&gt;We used to have this working with 10.7 and with ArcMap's arcpy, but this is trying to use a Pro 2.7 map.&amp;nbsp; Not sure how to set sharing public before the arcpy.&lt;SPAN&gt;UploadServiceDefinition_server.&amp;nbsp; The service is already published and both the regular map service and WMS items are already shared public.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;arcpy&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;os&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;xml.dom.minidom&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;DOM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#&amp;nbsp;Sign&amp;nbsp;into&amp;nbsp;Portal&amp;nbsp;and&amp;nbsp;publish&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;arcpy.SignInToPortal(portal_URL,&amp;nbsp;portal_pub_user,&amp;nbsp;portal_pub_pass)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#&amp;nbsp;Create&amp;nbsp;MapImageSharingDraft&amp;nbsp;and&amp;nbsp;set&amp;nbsp;metadata,&amp;nbsp;portal&amp;nbsp;folder,&amp;nbsp;and&amp;nbsp;server&amp;nbsp;folder&amp;nbsp;properties&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;MAP.getWebLayerSharingDraft(&lt;/SPAN&gt;&lt;SPAN&gt;"FEDERATED_SERVER"&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"MAP_IMAGE"&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;service_name)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.summary&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"summary"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.tags&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"tags"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.description&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"description"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.credits&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"credits"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.useLimitations&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"useLimitations&amp;nbsp;"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.serviceName&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;service_name&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.federatedServerUrl&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;server_URL&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.serverFolder&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"serverFolder"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.portalFolder&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"portalFolder"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.overwriteExistingService&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;True&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#&amp;nbsp;Create&amp;nbsp;Service&amp;nbsp;Definition&amp;nbsp;Draft&amp;nbsp;file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sharing_draft.exportToSDDraft(sddraft_output_filename)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#&amp;nbsp;Edit&amp;nbsp;SD&amp;nbsp;Draft&amp;nbsp;XML&amp;nbsp;to&amp;nbsp;enable&amp;nbsp;WMS&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;doc&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;DOM.parse(sddraft_output_filename)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;descriptions&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;doc.getElementsByTagName(&lt;/SPAN&gt;&lt;SPAN&gt;'Type'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;desc&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;descriptions:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;desc.parentNode.tagName&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;==&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'SVCManifest'&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;desc.hasChildNodes():&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;desc.firstChild.data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'esriServiceDefinitionType_Replacement'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;typeNames&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;doc.getElementsByTagName(&lt;/SPAN&gt;&lt;SPAN&gt;'TypeName'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;typeName&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;typeNames:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;#&amp;nbsp;Get&amp;nbsp;the&amp;nbsp;TypeName&amp;nbsp;we&amp;nbsp;want&amp;nbsp;to&amp;nbsp;enable.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;typeName.firstChild.data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;==&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'WMSServer'&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;extension&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;typeName.parentNode&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;keys&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;doc.getElementsByTagName(&lt;/SPAN&gt;&lt;SPAN&gt;'Key'&lt;/SPAN&gt;&lt;SPAN&gt;)&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;extElement&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;extension.childNodes:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;#&amp;nbsp;Enabled&amp;nbsp;WMS&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;extElement.tagName&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;==&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'Enabled'&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;extElement.firstChild.data&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'true'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;f&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;open(sddraft_output_filename,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'w'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;doc.writexml(f)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;f.close()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#&amp;nbsp;Stage&amp;nbsp;Service&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;arcpy.StageService_server(sddraft_output_filename,&amp;nbsp;sd_output_filename)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;#&amp;nbsp;Share&amp;nbsp;to&amp;nbsp;portal&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;arcpy.UploadServiceDefinition_server(in_sd_file&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;sd_output_filename,&amp;nbsp;in_server&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;portal_URL,&amp;nbsp;in_folder_type&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"EXISTING"&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;in_override&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"OVERRIDE_DEFINITION"&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;in_public&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"PUBLIC"&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;in_organization&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"SHARE_ORGANIZATION"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 03 Aug 2021 21:37:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1085520#M30822</guid>
      <dc:creator>JoeRogan</dc:creator>
      <dc:date>2021-08-03T21:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1090590#M30970</link>
      <description>&lt;P&gt;An enhancement was logged for this issue, noted below:&lt;/P&gt;&lt;P&gt;&lt;I&gt;ENH-000142251: Include a sharing capability parameter in the StageService_server() function in Arcpy.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;I&gt;The workaround is to leverage the Python API or the REST API directly (via requests module) to update the service to enable WMS capabilities AFTER it has been published&amp;nbsp;via ArcPy, using the edit() method on the Python API's service class, found here:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.server.html#arcgis.gis.server.Service.edit" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/api-reference/arcgis.gis.server.html#arcgis.gis.server.Service.edit&lt;/A&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;I&gt;For this to be possible, the JSON dictionary of the edits must contain all properties for the service. The easiest way to do this initially is to make this change manually in the Server Manager on the server site, and capture the edit operation made to the service. The JSON will look something like this:&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "serviceName": "20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png",
  "type": "MapServer",
  "description": "",
  "capabilities": "Map,Query,Data",
  "provider": "DMaps",
  "clusterName": "default",
  "minInstancesPerNode": 0,
  "maxInstancesPerNode": 0,
  "instancesPerContainer": "1",
  "maxWaitTime": "60",
  "maxStartupTime": 300,
  "maxIdleTime": "1800",
  "maxUsageTime": "600",
  "loadBalancing": "ROUND_ROBIN",
  "isolationLevel": "HIGH",
  "configuredState": "STOPPED",
  "recycleInterval": "24",
  "recycleStartTime": "00:00",
  "keepAliveInterval": 1800,
  "private": false,
  "isDefault": false,
  "maxUploadFileSize": 0,
  "allowedUploadFileTypes": "",
  "properties": {
    "maxDomainCodeCount": "25000",
    "cacheDir": "C:\\arcgis\\arcgisserver\\directories\\arcgiscache",
    "maxImageWidth": "4096",
    "maxRecordCount": "2000",
    "antialiasingMode": "Fast",
    "enableDynamicLayers": true,
    "dynamicDataWorkspaces": [],
    "isCached": false,
    "virtualOutputDir": "/rest/directories/arcgisoutput",
    "exportTilesAllowed": "false",
    "maxImageHeight": "4096",
    "cacheOnDemand": false,
    "minScale": "9027.9774109999998",
    "schemaLockingEnabled": true,
    "useLocalCacheDir": true,
    "outputDir": "C:\\arcgis\\arcgisserver\\directories\\arcgisoutput",
    "maxScale": "4513.9887049999998",
    "filePath": "C:\\arcgis\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png.MapServer\\extracted\\p20\\Updated_20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png.msd",
    "supportedImageReturnTypes": "URL",
    "maxSampleSize": "100000",
    "clientCachingAllowed": true,
    "userName": "siteadmin",
    "textAntialiasingMode": "Force",
    "maxExportTilesCount": "100000",
    "ignoreCache": false,
    "maxBufferCount": "100",
    "disableIdentifyRelates": false,
    "portalURL": "https://site.int/portal/",
    "dateFieldsTimezoneID": "",
    "dateFieldsRespectsDayLightSavingTime": false,
    "tilingScheme": 3,
    "maxLOD": "",
    "minLOD": "",
    "resampling": false
  },
  "portalProperties": {
    "isHosted": false,
    "portalItems": [
      {
        "itemID": "2654fcc55e2442ff8dab2ac8be9b44be",
        "type": "MapServer"
      }
    ]
  },
  "extensions": [
    {
      "typeName": "ValidationServer",
      "capabilities": "",
      "enabled": false
    },
    {
      "typeName": "WCSServer",
      "capabilities": null,
      "properties": {
        "name": "20210520_Pembina_127_14302_Athabasca River Right _South_ Slope_B206_2cm_png",
        "role": "",
        "title": "20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png",
        "defaultVersion": "2.0.1",
        "abstract": "",
        "keywords": "",
        "fees": "",
        "accessConstraints": "None",
        "responsiblePerson": "",
        "responsiblePosition": "",
        "onlineResource": "https://site.int/server/services/20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png/MapServer/WCSServer",
        "providerName": "",
        "phone": "",
        "fax": "",
        "contactInstructions": "",
        "email": "",
        "address": "",
        "city": "",
        "province": "",
        "zipcode": "",
        "providerWebsite": "",
        "serviceHour": "",
        "country": "",
        "customGetCapabilities": false,
        "pathToCustomGetCapabilitiesFiles": "",
        "maxImageHeight": "",
        "maxImageWidth": "",
        "SupportEOProfile": false
      },
      "enabled": false
    },
    {
      "typeName": "WFSServer",
      "capabilities": null,
      "properties": {
        "name": "20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png",
        "appSchemaURI": "https://site.int/server/services/20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png/MapServer/WFSServer",
        "role": "",
        "appSchemaPrefix": "20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png",
        "pathToStoredQueryFile": "",
        "enableTransactions": false,
        "title": "",
        "abstract": "",
        "keyword": "",
        "fees": "",
        "serviceType": "",
        "serviceTypeVersion": "",
        "deliveryPoint": "",
        "accessConstraints": "",
        "individualName": "",
        "positionName": "",
        "providerName": "",
        "onlineResource": "https://site.int/server/services/20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png/MapServer/WFSServer",
        "facsimile": "",
        "phone": "",
        "electronicMailAddress": "",
        "contactInstructions": "",
        "hourOfService": "",
        "providerSite": "",
        "administrativeArea": "",
        "city": "",
        "postalCode": "",
        "country": "",
        "pathToCustomGetCapabilitiesFiles": "",
        "customGetCapabilities": false,
        "transactionsWithoutLocks": false,
        "enableDefMaxFeatures": false,
        "defMaxFeaturesValue": "",
        "axisOrderWFS10": "longlat",
        "axisOrderWFS11": "longlat",
        "axisOrderWFS20": "longlat"
      },
      "enabled": false
    },
    {
      "typeName": "NAServer",
      "capabilities": null,
      "properties": {
        "nALayerDir": "C:\\arcgis\\arcgisserver\\directories\\arcgisoutput",
        "defaultOutputGeometryPrecision": "",
        "defaultOutputGeometryPrecisionUnits": "esriMeters",
        "saveLayerOnServerWhenError": false,
        "saveLayerOnServerWhenDebugging": false,
        "allowSaveLayerOnServer": true,
        "ignoreNetworkLocationFields": false,
        "usePortalTravelModes": false,
        "licensedForAutomaticRerouting": false,
        "route_MaxBarriers": "",
        "route_MaxStops": "",
        "route_MaxFeaturesInLineBarriers": "",
        "route_MaxFeaturesInPolygonBarriers": "",
        "route_AllowTimeWindows": "true",
        "route_ForceHierarchyBeyondDistance": "",
        "route_ForceHierarchyBeyondDistanceUnits": "esriMeters",
        "oDCostMatrix_MaxBarriers": "",
        "oDCostMatrix_MaxOrigins": "",
        "oDCostMatrix_MaxDestinations": "",
        "oDCostMatrix_MaxDestinationsToFind": "",
        "oDCostMatrix_MaxFeaturesInLineBarriers": "",
        "oDCostMatrix_MaxFeaturesInPolygonBarriers": "",
        "oDCostMatrix_ForceHierarchyBeyondDistance": "",
        "oDCostMatrix_ForceHierarchyBeyondDistanceUnits": "esriMeters",
        "locationAllocation_MaxFacilities": "",
        "locationAllocation_MaxFeaturesInPolygonBarriers": "",
        "locationAllocation_MaxFeaturesInLineBarriers": "",
        "locationAllocation_MaxBarriers": "",
        "locationAllocation_MaxDemandPoints": "",
        "locationAllocation_ForceHierarchyBeyondDistance": "",
        "locationAllocation_ForceHierarchyBeyondDistanceUnits": "esriMeters",
        "serviceArea_MaxBarriers": "",
        "serviceArea_MaxBreakValue_Time": "",
        "serviceArea_MaxBreakValue_TimeUnits": "esriTimeUnitsMinutes",
        "serviceArea_MaxBreakValue_Length": "",
        "serviceArea_MaxBreakValue_LengthUnits": "esriMeters",
        "serviceArea_MaxBreakValue_Other": "",
        "serviceArea_MaxFacilities": "",
        "serviceArea_MaxFeaturesInPolygonBarriers": "",
        "serviceArea_MaxFeaturesInLineBarriers": "",
        "serviceArea_ForceHierarchyBeyondDistance": "",
        "serviceArea_ForceHierarchyBeyondDistanceUnits": "esriMeters",
        "serviceArea_ForceHierarchyBeyondTime": "",
        "serviceArea_ForceHierarchyBeyondTimeUnits": "esriTimeUnitsSeconds",
        "serviceArea_ForceHierarchyBeyondOther": "",
        "vRP_MaxFeaturesInPolygonBarriers": "",
        "vRP_MaxRoutes": "",
        "vRP_MaxFeaturesInLineBarriers": "",
        "vRP_MaxOrders": "",
        "vRP_MaxBarriers": "",
        "vRP_ForceHierarchyBeyondDistance": "",
        "vRP_ForceHierarchyBeyondDistanceUnits": "esriMeters",
        "closestFacility_MaxIncidents": "",
        "closestFacility_MaxBarriers": "",
        "closestFacility_MaxFacilities": "",
        "closestFacility_MaxFacilitiesToFind": "",
        "closestFacility_MaxFeaturesInLineBarriers": "",
        "closestFacility_MaxFeaturesInPolygonBarriers": "",
        "closestFacility_ForceHierarchyBeyondDistance": "",
        "closestFacility_ForceHierarchyBeyondDistanceUnits": "esriMeters"
      },
      "enabled": false
    },
    {
      "typeName": "VersionManagementServer",
      "capabilities": "Create,Delete,VersionInfos,LockInfos,PurgeLock,StartEditing,StopEditing,StartReading,StopReading,DeleteForwardEdits,Alter,Differences,Reconcile,Conflicts,InspectConflicts,Post,RestoreRows,Diagnostics",
      "enabled": false
    },
    {
      "typeName": "NetworkDiagramServer",
      "capabilities": "",
      "enabled": false
    },
    {
      "typeName": "KmlServer",
      "capabilities": "SingleImage,SeparateImages,Vectors",
      "properties": {
        "minRefreshPeriod": "30",
        "compatibilityMode": "GoogleEarth",
        "imageSize": "1024",
        "dpi": "96",
        "endPointURL": "",
        "featureLimit": "1000000",
        "useDefaultSnippets": false
      },
      "enabled": false
    },
    {
      "typeName": "LRServer",
      "capabilities": "",
      "enabled": false
    },
    {
      "typeName": "WMSServer",
      "capabilities": "GetCapabilities,GetMap,GetLegendGraphic,GetSchemaExtension,GetFeatureInfo,GetStyles",
      "properties": {
        "name": "WMS",
        "title": "20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png",
        "abstract": "",
        "keyword": "",
        "fees": "",
        "accessConstraints": "",
        "contactPerson": "",
        "contactPosition": "",
        "onlineResource": "https://site.int/server/services/20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png/MapServer/WMSServer",
        "contactOrganization": "",
        "contactVoiceTelephone": "",
        "contactFacsimileTelephone": "",
        "contactElectronicMailAddress": "",
        "address": "",
        "city": "",
        "stateOrProvince": "",
        "postCode": "",
        "country": "",
        "addressType": "",
        "pathToCustomGetCapabilitiesFiles": "",
        "pathToCustomSLDFile": "",
        "inheritLayerNames": false,
        "customGetCapabilities": false,
        "reaspect": false,
        "listSupportedCRS": "",
        "listCustomCRS": ""
      },
      "enabled": true
    },
    {
      "typeName": "UtilityNetworkServer",
      "capabilities": "Trace,ValidateNetworkTopology,DisableSubnetworkController,EnableSubnetworkController,UpdateSubnetwork,ExportSubnetwork,QueryNetworkMoments,UpdateIsConnected,EnableTopology,DisableTopology,SynthesizeAssociationGeometries",
      "enabled": false
    },
    {
      "typeName": "ParcelFabricServer",
      "capabilities": "Build,Merge,Clip,CopyLinesToParcelType,DeleteParcels,ChangeParcelType,DuplicateParcels,AssignFeaturesToRecord,UpdateParcelHistory,CreateSeeds,AnalyzeByLeastSquaresAdjustment,ApplyLeastSquaresAdjustment",
      "enabled": false
    },
    {
      "typeName": "FeatureServer",
      "capabilities": "Create,Query,Update,Delete,Uploads,Editing",
      "properties": {
        "zDefaultValue": "0",
        "allowOthersToDelete": false,
        "allowOthersToUpdate": false,
        "allowOthersToQuery": true,
        "enableZDefaults": false,
        "realm": "",
        "editorTrackingTimeInUTC": "true",
        "editorTrackingTimeZoneID": "UTC",
        "editorTrackingRespectsDayLightSavingTime": "false",
        "enableOwnershipBasedAccessControl": false,
        "allowGeometryUpdates": true,
        "allowUpdateWithoutMValues": false,
        "allowTrueCurvesUpdates": true,
        "xssPreventionEnabled": true,
        "includeTopologyLayer": false,
        "syncEnabled": false,
        "syncVersionCreationRule": "versionPerDownloadedMap",
        "onlyAllowTrueCurveUpdatesByTrueCurveClients": true,
        "syncBranchVersionCreationRule": "versionPerDownloadedMap"
      },
      "enabled": false
    },
    {
      "typeName": "MaritimeChartService",
      "capabilities": "",
      "properties": {
        "comments": "Not to be used for navigation.",
        "controlFilesDirectory": "C:\\arcgisserver\\directories\\maritimeserver\\maritimechartservice\\",
        "keywords": "S-57",
        "workingDirectory": "C:\\arcgisserver\\directories\\maritimeserver\\maritimechartservice\\",
        "author": "ArcGIS for Maritime Server",
        "subject": "S-57 Web Services",
        "datasetsDirectory": "C:\\arcgisserver\\directories\\maritimeserver\\maritimechartservice\\",
        "title": "Maritime Chart Service",
        "category": "S-57",
        "supportsREST": "true",
        "supportsSOAP": "false",
        "supportsInterceptor": "false"
      },
      "enabled": false
    }
  ],
  "frameworkProperties": {},
  "datasets": [],
  "_ssl": true,
  "enabled": true
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This JSON dictionary is then passed to the edit() method, as in the Python script sample below, using the Python API:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;from arcgis.gis import GIS
import json

# Login to the GIS
gis = GIS(url='https://site.int/portal/home/', username='login', password='pass', verify_cert = False)

# Access its servers
gis_servers = gis.admin.servers.list()

# Grab the first server (incase its a multi machine deployment)
server1 = gis_servers[0]
print(type(server1))
print(server1)
# Validate to confirm server is listening
gis.admin.servers.validate()

# Get folders on server
folders = server1.services.folders
print(folders)

# Confirm the service exists
serviceExists = server1.services.exists(folder_name='/', name='20210520_Pembina_127_14302_Athabasca_River_Right__South__Slope_B206_2cm_png', service_type='MapServer')
print(serviceExists)

# Get the service
service = server1.services.list(folder='/')
print(service[2])

# Edit the service
with open("serviceJSON.json") as json_file:

  data = json.load(json_file)

service[2].edit(data)


print("Complete")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will update the newly published map service to enable the WMS capabilities on it.&lt;/P&gt;&lt;P&gt;NOTE: Minor alterations of the script will be necessary given your scenario. Most importantly is the service pulled from the List() method on line 26. My specific service I was updated was the 3rd in the list, yours will differ.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 20:35:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1090590#M30970</guid>
      <dc:creator>TomThompsonEsriCA</dc:creator>
      <dc:date>2021-08-19T20:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1090607#M30971</link>
      <description>&lt;P&gt;In addition to Tom's solution below, I implemented a slightly different approach which basically simulates the REST requests in Server Manager.&amp;nbsp; Thanks Tom for&amp;nbsp; logging this issue and enhancement!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;  # Turning on WMS capability starts here

  # Generate a token for accessing the REST admin
  token_response = requests.post(token_URL, data = {
    "f": "json",
    "client": "referer",
    "referer": portal_URL,
    "username": portal_pub_user,
    "password": portal_pub_pass,
    "expiration": 60
  })
  token = token_response.json()["token"]

  # Request the service data
  service_data_reponse = requests.post(service_admin_URL, data = {
    "f": "json",
    "token": token
  })
  service_data = service_data_reponse.json()

  # Enable the WMS extension and add metadata in the service description
  for extension in service_data["extensions"]:
    if (extension["typeName"] == "WMSServer"):
      extension["enabled"] = "true"
      extension["properties"]["keyword"] = ""

  # Edit the service with the new service data
  edit_response = requests.post(service_admin_URL + "/edit", data = {
    "f": "json",
    "token": token,
    "service": json.dumps(service_data),
    "runAsync": "true"
  })

  # Wait 30 seconds for the service to restart before sharing
  time.sleep(30)

  # Find and share the new WMS item in Portal
  egis = arcgis.GIS(url=portal_URL, username=portal_pub_user, password=portal_pub_pass, verify_cert=True)
  wms_items = egis.content.search(query=service_name, item_type="WMS")
  for wms_item in wms_items:
    if (wms_item.owner == portal_pub_user):
      wms_item.share(everyone=True, org=True)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2021 20:58:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1090607#M30971</guid>
      <dc:creator>JoeRogan</dc:creator>
      <dc:date>2021-08-19T20:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1291582#M36019</link>
      <description>&lt;P&gt;Hi Joe,&lt;/P&gt;&lt;P&gt;how did you solve this problem? Did you use the suggested way via the Python API?&lt;/P&gt;&lt;P&gt;kind regards,&lt;/P&gt;&lt;P&gt;Timo&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 13:54:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1291582#M36019</guid>
      <dc:creator>TWickiSLU</dc:creator>
      <dc:date>2023-05-22T13:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1291617#M36023</link>
      <description>&lt;P&gt;Ah sorry, I have only just seen your solution&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 15:06:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1291617#M36023</guid>
      <dc:creator>TWickiSLU</dc:creator>
      <dc:date>2023-05-22T15:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1292105#M36038</link>
      <description>&lt;P&gt;In my case the "service_data" JSON output looks like this ("supportedExtensions" instead "extensions" because of a different version?):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
"currentVersion":10.91,
"cimVersion":"2.9.0",
"serviceDescription":"Bibliotheken - Standort und Informationen.",
"mapName":"gis_citymaps",
"description":"Bibliotheken - Standort und Informationen.",
"copyrightText":"xxx",
"supportsDynamicLayers":true,
"layers":[
"xxx"
],
"tables":[

],
"spatialReference":"xxx",
"singleFusedMapCache":false,
"initialExtent":"xxx",
"fullExtent":"xxx",
"datesInUnknownTimezone":false,
"minScale":0,
"maxScale":0,
"units":"esriMeters",
"supportedImageFormatTypes":"PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP",
"documentInfo":"xxx",
"Title":"Map",
"Author":"",
"Comments":"",
"Subject":"",
"Category":"",
"AntialiasingMode":"None",
"TextAntialiasingMode":"Force",
"Version":"2.9.0",
"Keywords":"Bildung,POI",
"capabilities":"Map,Query,Data",
"supportedQueryFormats":"JSON, geoJSON, PBF",
"exportTilesAllowed":false,
"referenceScale":0.0,
"datumTransformations":[
"xxx"
],
"supportsDatumTransformation":true,
"floorAwareMapProperties":"xxx",
"archivingInfo":"xxx",
"supportsClipping":true,
"supportsSpatialFilter":true,
"supportsTimeRelation":true,
"supportsQueryDataElements":true,
"maxRecordCount":2000,
"maxImageHeight":4096,
"maxImageWidth":4096,
"supportedExtensions":"FeatureServer, WFSServer",
"resampling":false,
"serviceItemId":"ddfa469bf5024d728a5da7a0f6310768"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Therefore I adjustet the script like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import arcgis
import requests
import time
import json

portal_url = "https://xxx/portal"
token_url = "https://xxx/portal/sharing/rest/generateToken"
portal_pub_user = "xxx"
portal_pub_pass = "xxx"
service_url = "https://xxx/server/rest/services/OGD/hochschule/MapServer"
service_admin_url = "https://xxx/server/rest/services/OGD/hochschule/MapServer/admin"

# Generate a token for accessing the REST admin
token_response = requests.post(token_url, data = {
    "f": "json",
    "client": "referer",
    "referer": portal_url,
    "username": portal_pub_user,
    "password": portal_pub_pass,
    "expiration": 60
  })
token = token_response.json()["token"]

# Request the service data
service_data_reponse = requests.post(service_url, data = {
    "f": "json",
    "token": token
})
service_data = service_data_reponse.json()

# Enable the WMS extension and add metadata in the service description
service_data["supportedExtensions"] = 'FeatureServer, WFSServer, WMSServer'

# Edit the service with the new service data
edit_response = requests.post(service_admin_url + "/edit", data = {
    "f": "json",
    "token": token,
    "service": json.dumps(service_data),
    "runAsync": "true"
})

# Wait 30 seconds for the service to restart before sharing
time.sleep(30)

# Find and share the new WMS item in Portal
egis = arcgis.GIS(url=portal_url, username=portal_pub_user, password=portal_pub_pass, verify_cert=True)
wms_items = egis.content.search(query="hochschule", item_type="WMS")
for wms_item in wms_items:
    if (wms_item.owner == portal_pub_user):
        wms_item.share(everyone=True, org=True)

&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;The edit_response is valid (200) but WMS gets not activated ("supportedExtensions" still without WMSServer). Do you have any idea what I am doing wrong?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;Timo&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 14:54:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1292105#M36038</guid>
      <dc:creator>TWickiSLU</dc:creator>
      <dc:date>2023-05-23T14:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1292458#M36042</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My&amp;nbsp;service_admin_url was wrong. It works with the correct one:&lt;BR /&gt;&lt;BR /&gt;service_admin_url&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;A href="https://xxx/server/admin/services/OGD/hochschule.MapServer" target="_blank"&gt;https://xxx/server/admin/services/OGD/hochschule.MapServer&lt;/A&gt;"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 24 May 2023 08:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1292458#M36042</guid>
      <dc:creator>TWickiSLU</dc:creator>
      <dc:date>2023-05-24T08:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1293069#M36074</link>
      <description>&lt;P&gt;My final solution without using "request" module. The entire script is found here:&amp;nbsp;&lt;A href="https://github.com/wickit7/arcgisportalmanagement" target="_blank"&gt;wickit7/arcgisportalmanagement: Scripts to publish ArcGIS services and webtools and scripts to migrate ArcGIS Portal users, groups and items. (github.com)&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcgis, time, json

## Input parameter (example -&amp;gt; later JSON)
portal_url = "https://xxx/portal"
federated_server_url = "https://xxx/server"
sign_in_user = "xxx"
pw = "xxx"
service_name = "hochschule"
server_folder = "OGD"
portal_folder = "Betrieb OGD"
enable_extensions =  ["FeatureServer" ,"WMSServer", "WFSServer"]
share_everyone = True
share_org = False

metadata = {
    "credits": "© xxx",
    "description": "Playground places",
    "summary": "Playground places used to test the publishing of a service",
    "tags": "test",
    "use_limitations": "xxx"
}

## Publish Service (arcpy.sharing)
# ...
## Use ArcGIS API for Python for further settings
# log in to portal
print('Connect to portal for using ArcGIS API for Python')
gis = arcgis.GIS(url=portal_url, username=sign_in_user, password=pw, verify_cert=False)
print(f"target portal: {gis}")

# get the index of the server where the service was published
gis_servers_properties = gis.admin.servers.properties
server_index = None
for ii, server_prop in enumerate(gis_servers_properties.servers): # assuming servers have same indexes as in target.admin.servers.list()
    if server_prop.url == federated_server_url:
        server_index = ii
        break

# get the correct server
server = gis.admin.servers.list()[server_index]

print(f'Search service on server {server_prop.url}')
# get the service
service = None
for service in server.services.list(server_folder): # assuming there is only one service with that name in that server folder
    if service.properties.serviceName == service_name:
        break

# Retrieve the service information
service_data = service.properties

# enable the extensions
if enable_extensions:
    print(f'Enable the service extensions: {enable_extensions}')
    for extension in service_data["extensions"]:
        if extension["typeName"] in enable_extensions:
            if share_everyone != True and extension["typeName"] in ["WFSServer", "WMSServer", 'WCSServer']:
                print(f'00297: {extension["typeName"]} layers must be shared with everyone')
            extension["enabled"] = "true"
            extension["properties"]["keyword"] = ""
    # convert PropertyMap to json
    service_data_json = json.dumps(dict(service_data))
    # Edit the service
    edit_respone = service.edit(service_data_json)
    # Wait 30 seconds for the service to restart
    time.sleep(30)
    # Retrieve the updated service information
    service_data = service.properties

# get the poral items of the published service
for portal_item in service_data["portalProperties"]["portalItems"]:
    item_id = portal_item["itemID"]
    items = gis.content.search(query=f"id:{item_id}")
    if items:
        item = items[0]
    else:
       print(f'Item not found with the specified itemID "{item_id}".')
    # move the item to the portal folder
    print(f'Move item "{item.title}" of type "{item.type}" to the folder "{portal_folder}"' )
    item.move(portal_folder, gis.users.me.username)
    # update item with metadata
    item.update(metadata)
    # share item
    print(f'Share item public:"{share_everyone}", organisation:"{share_org}"' )
    item.share(everyone=share_everyone, org=share_org)

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 14:45:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1293069#M36074</guid>
      <dc:creator>TWickiSLU</dc:creator>
      <dc:date>2023-05-25T14:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing map service with WMS capability with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1348166#M37647</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/231538"&gt;@JoeRogan&lt;/a&gt;&amp;nbsp;, &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/473911"&gt;@TWickiSLU&lt;/a&gt;&amp;nbsp;I think this issue has been resolved with the &lt;A href="https://www.esri.com/content/dam/esrisites/en-us/media/products/arcgis-pro-issues-addressed/arcgis-pro-3-2-issues-addressed.pdf" target="_self"&gt;release&lt;/A&gt;&amp;nbsp;of ArcGIS Pro 3.2. See the &lt;A href="https://www.esri.com/content/dam/esrisites/en-us/media/products/arcgis-pro-issues-addressed/arcgis-pro-3-2-issues-addressed.pdf" target="_self"&gt;release notes&lt;/A&gt; and details of &lt;A href="https://support.esri.com/en-us/bug/staging-a-web-feature-service-wfs-using-python-fails-an-bug-000159853" target="_self"&gt;BUG-00159853.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Please correct me if I am wrong and this post is a slight different issue.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2023 10:42:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/publishing-map-service-with-wms-capability-with/m-p/1348166#M37647</guid>
      <dc:creator>Jelle_Stu_PR</dc:creator>
      <dc:date>2023-11-10T10:42:04Z</dc:date>
    </item>
  </channel>
</rss>

