现在的位置: 首页 > 综合 > 正文

如何采用Local方式连接到ArcGIS Server

2013年08月12日 ⁄ 综合 ⁄ 共 1082字 ⁄ 字号 评论关闭

在使用ArcGIS Server ArcObjects API的时候,一般都需要首先以local方式连接到GIS Server,那么在9.2版本中有两个类可以连接到GIS Server。一个是ESRI.ArcGIS.Server.GISServerConnectionClass类,另一个是ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection类。

ESRI.ArcGIS.Server.GISServerConnectionClass类是对COM类封装以后的.NET类,在连接GIS Server时没有显式的指定用户,那么连接GIS Server是使用的是什么用户呢?其实是使用的web应用的用户,如果在web.config中有identity的节点,那么就是它了。连接的代码如下:

[C#]
ESRI.ArcGIS.Server.GISServerConnectionClass gisconnection;
gisconnection = new ESRI.ArcGIS.Server.GISServerConnectionClass();
gisconnection.Connect("servername");
ESRI.ArcGIS.Server.IServerObjectManager som = gisconnection.ServerObjectManager;

ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection类是一个纯粹的.NET类,其实整个ESRI.ArcGIS.ADF.Connection类库中的类都是.NET类。我们在连接server时最好使用AGSServerConnection。这个类需要显式的指定身份信息,用法如下:

[C#]
ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity("user", "passwd", "domain");
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconnection;
agsconnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("hostname", identity);
agsconnection.Connect();
IServerObjectManager som = agsconnection.ServerObjectManager;

抱歉!评论已关闭.