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

原文出自:http://blog.csdn.net/junmail/archive/2008/05/14/2444436.aspx

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

在使用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;

 

posted @ 2009-05-16 12:27  Candyxiaoqiang  阅读(368)  评论(0编辑  收藏  举报