WMSLayer (WMSServiceDescripion/WMSLayerDescription) programatically

Discussion created by cankorusa on Feb 8, 2011

I have a generic WMS server with the GetCapabilities turned off. I know the service info and the layer info for layers that I want to display in ArcMap via my addin. I can confirm that the GetMap works as per my info.

Any ideas on how to create my layer in the java API? It seems that I would need to create the WMSLayerDescription programatically (and possibly the WMSServiceDescription) but I can't seem to find an interface to let me do that. By default the com.esri.arcgis.gisclient makes a getcaps call to the server and I need to get around that.

Any code samples would be greatly appreciated. My current code is located below...

/// code snippet
IWMSGroupLayer wmsMapLayer = new WMSMapLayer();
PropertySet propSet = new PropertySet();

propSet.setProperty("URL", "http://"+serverPost.getmServer()+":"+serverPost.getmPort()+"/mapserver?");
 WMSConnectionName connName = new WMSConnectionName();
 IDataLayer dataLayer =  new com.esri.arcgis.carto.IDataLayerProxy (wmsMapLayer);

//want to avoid this... I know what the service info is and want to populate automatically ... I don't want a getcapabilities to go off to the server...    
 IWMSServiceDescription serviceDesc  = wmsMapLayer.getWMSServiceDescription();
 ILayer newLayer = null;
for(int i = 0;i < serviceDesc.getLayerDescriptionCount();i++){
    // I know what the layer description is and I want to generate this myself in code         
    IWMSLayerDescription layerDesc = serviceDesc.getLayerDescription(i);
 if (layerDesc.getLayerDescriptionCount() ==0){
     IWMSLayer newWMSLayer = wmsMapLayer.createWMSLayer(layerDesc);
 newLayer = new com.esri.arcgis.carto.ILayerProxy (newWMSLayer);               
 // this traverses through all of the layers to find the one we want
   for (int s=0; s <= layerDesc.getLayerDescriptionCount();s++){
   IWMSLayer newWMSLayer = wmsMapLayer.createWMSLayer(layerDesc.getLayerDescription(s));              
   newLayer = new com.esri.arcgis.carto.ILayerProxy (newWMSLayer);
   //if (newLayer.getName().equalsIgnoreCase("1metercalif")){
   if (newLayer.getName().equalsIgnoreCase(title)){
ILayer layer = new com.esri.arcgis.carto.ILayerProxy (wmsMapLayer);
mxDocument.getFocusMap().addLayer(new com.esri.arcgis.carto.ILayerProxy (layer) );
 IActiveView activeView = mxDocument.getActiveView();