I have a wms layer in the map that I want to programmatically save as a layer file. Using
doesn't seem to work with wms layers. As an experiment, within ArcGIS Pro I tried the corresponding Save to Layer File tool in the Data Management toolbox and it ignores the wms layer, so I'm guessing that is why my code doesn't work. However, within Pro you can right click on the wms layer in the TOC and select Sharing > Save As Layer File and this does work, so I'm wondering if there is some way to access this programmatically.