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?
Solved! Go to Solution.
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
Hi @MartinScheiber1 for me, when i create a new image draft file it create a black image layer and WMS as i am not referencing the data but copying it and also using ImageSDDraft. I think its because all information is still in old draft file and the new one just contains the WMS paramaters. Could you tell me how can i fix that?
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
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
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.
Hi @MartinScheiber1 for me, when i create a new image draft file it create a black image layer and WMS as i am not referencing the data but copying it and also using ImageSDDraft. I think its because all information is still in old draft file and the new one just contains the WMS paramaters. Could you tell me how can i fix that?