ArcGIS Enterprise and Python: How to automatize sharing weblayers that offer WMS/WFS capabilities?

436
4
Jump to solution
11-27-2020 02:00 AM
MartinScheiber1
New Contributor III

I have to create web services on ArcGIS Enterprise 10.8.1 (via ArcGIS Pro 2.6.3) that offer WMS/WFS capabilities from several hundred datasets coming from SDE databases. While this is not a problem when being done manually (I simply check the respective check boxes when using "Share as a Web Layer" - see image below), I am not able to find a way how to do that with Python.

 

 

In Python I have been using getWebLayerSharingDraft, exportToSDDraft, arcpy.StageService_server and arcpy.UploadServiceDefinition_server. This works pretty well, however, I only end up with a Map Image Service and Feature Service and have no idea how to get WMS and WFS. There seems to be no option to also create those services. Any suggestions?

0 Kudos
2 Solutions

Accepted Solutions
CalvinLietz
Esri Contributor

Hi Martin,

As far as I know, services with WFS capabilities can only be published from ArcGIS for Desktop. Therefore, it seems consistent that we would have to use the Python tools included in ArcGIS for Desktop, rather than those from ArcGIS Pro. Specifically, we will have to use the arcpy.mapping.CreateMapSDDraft method.

In the Code Sample section of the above documentation, go to "Modify SDDraft example 3". Here, we can see an example of enabling WMS capabilities on an SD file before publishing the service to ArcGIS server. Using an identical workflow, I believe you should b e able to enable WFS capabilities as well. Can you give this a shot?

Thanks,

Calvin

View solution in original post

inolaroch
New Contributor III

Hey @MartinScheiber1 ,

Can u post the full script please !

Thank you !

View solution in original post

4 Replies
CalvinLietz
Esri Contributor

Hi Martin,

As far as I know, services with WFS capabilities can only be published from ArcGIS for Desktop. Therefore, it seems consistent that we would have to use the Python tools included in ArcGIS for Desktop, rather than those from ArcGIS Pro. Specifically, we will have to use the arcpy.mapping.CreateMapSDDraft method.

In the Code Sample section of the above documentation, go to "Modify SDDraft example 3". Here, we can see an example of enabling WMS capabilities on an SD file before publishing the service to ArcGIS server. Using an identical workflow, I believe you should b e able to enable WFS capabilities as well. Can you give this a shot?

Thanks,

Calvin

View solution in original post

MartinScheiber1
New Contributor III

Hi Calvin,

Thanks a lot for your answer. I also stumbled across the article you mentioned and indeed it seems that one has to go a layer deeper and programmatically edit the sddraft (XML) file to make it work. I am still struggling with some minor issues, but it seems to work. Thanks a lot for your help.

Martin

0 Kudos
inolaroch
New Contributor III

Hey @MartinScheiber1 ,

Can u post the full script please !

Thank you !

View solution in original post

MartinScheiber1
New Contributor III

Hi @inolaroch,

you can find code samples here

Scroll down to Modify SDDraft example 1-7. Example 3 activates WMS capabilities. Activating WFS works in a similar way.

Please see the code I use below:

## ENABLE WMS
if typeName.firstChild.data == 'WMSServer':
    extension = typeName.parentNode
    for extElement in extension.childNodes:
        # Enable WMS.
        if extElement.tagName == 'Enabled':
            extElement.firstChild.data = 'true'


## ENABLE WFS
if typeName.firstChild.data == 'WFSServer':
    extension = typeName.parentNode
    for extElement in extension.childNodes:
        # Enable WFS.
        if extElement.tagName == 'Enabled':
            extElement.firstChild.data = 'true'

I hope that helps.

0 Kudos