关闭

ArcEngine访问ArcGISServer服务【一】

标签: ArcGISesri
1598人阅读 评论(0) 收藏 举报
分类:

GISClient类库允许开发者使用Web服务,这些Web服务可以由ArcIMSArcGIS Server提供。GISClient类库中包含用于连接GIS服务器以使用Web服务的对象。该类库支持ArcIMS的图像和要素服务。GISClient类库提供以无态方式直接或通过Web服务目录操作ArcGIS Server对象的通用编程模型。在ArcGIS Server上运行的ArcObjects组件不能通过GISClient接口来访问。要直接获得访问在服务器上运行的ArcObjects,开发人员应使用Server类库中的功能。

 

代码实现部分:

 

Ø  打开连接

 

private void OpenConn(bool bLAN,string sval)

 

        {

 

            try

 

            {

 

               IAGSServerConnectionFactory pConnF = new AGSServerConnectionFactory();

 

               IPropertySet pProSet = new PropertySet();

 

               if(bLAN)

 

                   pProSet.SetProperty(“machine”, sval);

 

               else

 

                   pProSet.SetProperty(“url”, sval);

 

               clsPublic.pConn = pConnF.Open(pProSet, 0);

 

                if(clsPublic.pConn != null)

 

                {

 

                   MessageBox.Show(“连接成功“, “提示“, MessageBoxButtons.OK, MessageBoxIcon.Information);

 

                }

 

               else

 

                {

 

                   MessageBox.Show(“连接失败“,”提示“, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

 

                }

 

            }

 

            catch {}

 

        }

 

 

Ø  加载地图

 

publicvoid AddMapService(AxMapControl pMapCtrl, string sServiceName, IAGSServerConnection pConn)

 

       {

 

           pConn.ServerObjectNames.Reset();

 

           IAGSEnumServerObjectName pEnumServerObjectNames =pConn.ServerObjectNames;

 

           pEnumServerObjectNames.Reset();

 

           IAGSServerObjectName pServerObjectName =pEnumServerObjectNames.Next();

 

           IAGSServerObjectName sServerObjectName = null;

 

           while (pServerObjectName != null)

 

           {

 

                if(pServerObjectName.Name == sServiceName)

 

                {

 

                    sServerObjectName =pServerObjectName;

 

                    break;

 

                }

 

                pServerObjectName =pEnumServerObjectNames.Next();

 

           }

 

           if (sServerObjectName == null)

 

           {

 

                MessageBox.Show(没有找到对应的MapService, 提示, MessageBoxButtons.OK,MessageBoxIcon.Exclamation);

 

                return;

 

           }

 

           IName pName = sServerObjectName asIName;

 

           IMapServer pMapServer = pName.Open() asIMapServer;

 

           IMapServerLayer pMSLyr = newMapServerLayerClass();

 

           pMSLyr.ServerConnect(sServerObjectName, pMapServer.DefaultMapName);

 

           ILayer plyr = pMSLyr asILayer;

 

           pMapCtrl.ClearLayers();

 

           pMapCtrl.AddLayer(plyr);

 

           pMapCtrl.Extent = pMapCtrl.FullExtent;

 

       }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:403789次
    • 积分:6854
    • 等级:
    • 排名:第3509名
    • 原创:292篇
    • 转载:3篇
    • 译文:1篇
    • 评论:36条
    最新评论