Hi all,I am trying to add map service in ArcDesktop using ArcObjects.I am able to add mapserver type service as a layer into ArcDesktop.but code is not working for KMLServer type service.Red colour step is throwing error for KML server type service.I tried to type cast IMapServer to IKmlserver but no success.
string URL = "http://server.arcgisonline.com/ArcGIS/rest/services/";
string serverObjName = "World_Street_Map";
IMap pMap = map;
IMxDocument pMxDoc;
IActiveView pAV;
ESRI.ArcGIS.GISClient.IAGSServerConnectionFactory pAGSServerConnectionFactory = new ESRI.ArcGIS.GISClient.AGSServerConnectionFactory();
IPropertySet2 pProps = new PropertySet() as IPropertySet2;
ESRI.ArcGIS.GISClient.IAGSServerConnection pAGSConnection;
ESRI.ArcGIS.GISClient.IAGSEnumServerObjectName pEnumSOName;
ESRI.ArcGIS.GISClient.IAGSServerObjectName pSOName = null;
IName pName = null;
IMapServer pMapServer;
IMapServerLayer pMSLayer = new MapServerLayer() as IMapServerLayer;
pProps.SetProperty("URL", URL);
try
{
pAGSConnection = pAGSServerConnectionFactory.Open(pProps, 0);
pEnumSOName = pAGSConnection.ServerObjectNames;
while ((pSOName = pEnumSOName.Next()) != null)
{
if (pSOName.Name.Contains(serverObjName))
{
pName = (IName)pSOName;
break;
}
pSOName = pEnumSOName.Next();
}
pMapServer = (IMapServer)pName.Open();
pMSLayer.ServerConnect(pSOName, pMapServer.DefaultMapName);
pMxDoc = ((IMxDocument)(app.Document));
pMap = pMxDoc.FocusMap;
pMap.AddLayer((ILayer)pMSLayer);
Is there any other way to access KMLserver type object?Any help would be appreciated.Regards,Prashant