2010年7月20日_周二_Accessing ArcGIS Server from a Web application

Accessing ArcGIS Server from a Web application

通过WEB应用程序访问ArcGISServr地图服务

The Web ADF provides the components necessary to work with ArcGIS Server services.  The Web ADF controls utilize the Common API implementation classes for both ArcGIS Server local and internet data sources.  ArcGIS Server local data sources connect to the ArcGIS Server Object Manager (SOM) and work with a server object directly.  ArcGIS Server internet data sources connect to an ArcGIS Server Web service endpoint.   A number of base classes (e.g. MapResourceBase, GISDataSourceBase) define shared members for both ArcGIS Server data source types, but different implementation and proxy classes are used to initiate and manage the connection with an ArcGIS Server service.  The Web ADF works with local and internet ArcGIS Services using the ArcGIS Server SOAP API.  To put this another way, the ArcGIS Server data source implementation(落实,实施) of the Web ADF Common API uses the ArcGIS Server SOAP API.  This means that almost all interaction between Web ADF controls and Common API implementation classes with ArcGIS Server data sources use SOAP.  See the ArcGIS Server implementation discussion for more details.  Note that an ArcGIS Server local data source can access server context to create and work with objects on the server via ArcObjects COM proxies on the client.  However, the Web ADF is unaware(不知道,没有感觉到) of these changes unless you explicitly(明确的) inform the Web ADF components.   Use the following walkthrough as an introduction to working with ArcGIS Server data sources in a Web ADF application.  Programming with both SOAP API Value objects on the client and ArcObjects API COM objects on the server will be demonstrated(论证、证实). 

Web ADF提供了访问ArcGISServer 服务必须的组件。Web ADF 控件利用通用API实施类来访问本地和互联网上的数据源。ArcGISServer 本地数据源和SOM想连接并直接同一个server服务对象工作。 ArcGIS Server互联网数据源于ArcGIS Server网络服务点相互连接。许多的基础类定义了对于所有的ArcGIS Server数据源类型的公共成员,但是不同的实施类和代理类被用来初始化和管理ArcGISServer服务之间的连接。Web ADF 使用ArcGISServer spap API 与本地和网络上的ArcGISServer服务一起工作。为了用另一种方式来实现他,ArcGISServer 数据源使用ArcGSIServer SOAP API来实现Web ADF通用API.

这就意味着,Web ADF 和通用API实施类与ArcGISServer 数据源之间的交互都要使用SOAP。更多的资料查看ArcGIS Server implementation discussion 。请注意:一个ArcGISServer 本地数据源可以通过访问SeverContext通过客户端的ArcObject COM代理在服务器上创建对象并与之工作。尽管如此,Web ADF 任然没有感觉到这些变化,除非你明确的通知Web ADF组件。下面的内容讲解了在一个ADF应用程序内如何使用ArcGISServer数据源工作。在客户端SOAP API 对象以及服务器端的AP API的编程都经会被证实。

This tutorial will provide step-by-step instructions for creating a Web ADF application in Visual Studio 2005 that works with an ArcGIS Server local data source.  A custom tool will be created and used to add a graphic point to the Map using ArcGIS Server Value objects and buffer that point using ArcObjects on the GIS Server.  The following Web ADF controls will be used: MapResourceManager, Map, Toc, Toolbar.   

接下来的教程里面一步一步介绍了如何在VS2005里面使用ArcGISServer 本地数据源创建一个Web ADF 应用程序。我们还会创建一个自定义的工具,在ArcGISServer上使用ArcGSIServer 值对象来实现向地图上添加一个几何的点要素,使用ArcObjects 来对这个点进行缓冲区分析。我们将会使用下面的控件:MapResourceManager,Map,Toc,Toolbar.

1:Create a new Web application using the steps in the Creating a Web application with the Web controls tutorial.  When adding a MapResourceInfo, select an ArcGIS Server local data source. For the purposes of this tutorial, do not choose a cached map service. For cached services, you would use a Web ADF graphics layer instead of adding custom graphics to the map as you will do in this tutorial. 
The Web ADF application should appear as follows:

根据上面的教程创建一个应用程序,当添加一个MapResourceInfo的时候,选择一个ArcGIS Server 本地数据源。在本次教程里面,不要选择一个缓存的地图服务,对于缓存的服务,你需要使用一个Web ADF几何图层而不是像这个教程里面将要做的那样添加一个自定义的几何图层到地图。

这个Web ADF应用程序应该像下面的一样。

2:Add an ArcGIS identity(身份) to the web application. This is required when using ArcGIS Server local data sources. To add an identity, right-click on the project in the Solution Explorer window of Visual Studio, and choose Add ArcGIS Identity... from the context menu. This displays the Add ArcGIS Identity dialog. Enter the user name, password, and domain or machine name for the account you wish to use for this application.

在应用程序中注册一个ArcGIS 身份。当我们使用ArcGIS Server 本地数据源的时候,这个操作是必须的。为了注册一个身份,在VS解决访问管理窗口中单击鼠标右键,弹出一个快捷菜单,选择“Add ArcGIS Identity…”,这个调出身份注册窗口,输入你想在这个应用程序中使用的账户信息:用户名称,用户密码,以及服务的计算机名称。

The account used in the identity must be an existing account that is a member of the agsusers or agsadmin group on the machine where the ArcGIS Server Object Manager (SOM) runs. The account must also be recognized by the computer where you are running Visual Studio. Therefore, if the SOM is not running on the local Visual Studio machine, the account must be a domain account, and the local Visual Studio computer must be a member of the domain.

This step adds the identity with credentials(证明、资格) to the web.config file in the web application.  By default the credentials are encrypted(加密的).

我们注册的用户必须是在ArcGISSERVER服务其上的agsusr或者agsadmin用户组里面的一个存在的用户,账户也必须在应用程序部署的计算机上得到识别。因此,如果SOM没有运行在本地的机器那么这个账户就必须是一个域账户,并且本地的计算机必须是一个域的成员。

这一部将会将身份信息注册到网络应用程序中的配置文件里面,默认的情况下,配置文件里面的这个证明是经过加密的。

3:In Solution Explorer, right-click the Web project and select "Add New Item...".  In the Add New Item dialog, under the Visual Studio Installed Templates section, select the "Class" item.  Set the class file name to "PointBufferTool.cs" and make sure the language is "Visual C#" (Alternatively, you can use VB.NET. Code is provided in both languages below). Visual Studio will prompt(提示) you to create an "App_Code" folder and place the new class file inside.  Click Yes.  The PointBufferTool.cs file should open for you to start adding content.  This file will contain the executable code associated with the custom tool.

在解决方案资源管理窗口中,右键单击鼠标,选择“Add NewItems。”,在创建新项对话框里面,在VS安装的文件模板里面,我们选择”Class”项,设置文件的名称为:PointBufferTool.cs,并却确定我们所使用的语言是C#,VS将会提示你创建一个“App_Code”文件夹,并将我们新创建的文件,放置到这个文件夹里面。选择【YES】。PointBufferTool.CS

将会处于打开状态等待着你的输入。这个文件将会包含与用户工具相关的可执行的代码。

4:In Solution Explorer, right-click the Web project and select "Add ArcGIS Reference...". This dialog works similarly to the Add Reference dialog, but only shows ArcGIS-related assemblies.  A couple of ArcObjects Primary Interop Assemblies(集合) need to added to the project to work with ArcObjects remotely via the ArcGIS Server ArcObjects API.   In addition, the Web ADF Common API implementation of ArcGIS Server data sources, contained in the 

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer assembly, enables you to work with ArcGIS Server capabilities(能力,才能) exposed by Web ADF controls (e.g. MapFunctionality).  It also provides the ability to hook into(卷入) ArcObjects on the server via server context.  The value objects and proxies utilized by the Web ADF to work with ArcGIS Server data sources are contained in the ESRI.ArcGIS.ADF.ArcGISServer assembly. In the dialog, select the following components, click Add, then Finish:

在解决方案管理窗口中,我们单击鼠标右键,在弹出的快捷菜单里面我们选择“Add

ArcGIS  Rreference….”。这个窗口和“Add Reference、、、”窗口是非常的类似的,但是仅仅是显示和ArcGIS 相关的接口。两个重要的AO集合需要添加到工程中,通过ArcGIS Server AO API远程与AO对象一起工作。另外,Web ADF Common API中ArcGIS Server数据源的实施是包含在ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer集合中的,让你能够与Web ADF提供的ArcGIS Server的能力一起工作。她还提供了提供了通过Server context 进入服务器山的AO的能力。在对话框里面,我们选择下面的组件,单击Add,然后完成,退出。

ESRI.ArcGIS.ADF.ArcGISServer

ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer

ESRI.ArcGIS.Carto

ESRI.ArcGIS.Display

ESRI.ArcGIS.Geometry

ESRI.ArcGIS.Server

ESRI.ArcGIS.System

After selecting these components, click Add, then click Finish. The reference items are added to the web.config file and are available to use within the web project.

选择相应的组件后,单击添加,然后单击Finish完成。这些接口将会被添加到网络的配置文件里面,然后我们在WEB工程里面就可以使用这些接口了。

5:At the top of the PointBufferTool.cs file, add the following using statements:

在PointBufferTool.cs文件的上面,将下面的声明添加到文件的头部。

C#

using ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools;

using ESRI.ArcGIS.ADF.Web.UI.WebControls;

using ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer;

using ESRI.ArcGIS.Carto;

using ESRI.ArcGIS.Display;

using ESRI.ArcGIS.Geometry;

using ESRI.ArcGIS.esriSystem;

using ESRI.ArcGIS.Server;

6:Remove the PointBufferTool constructor and implement the IMapServerToolAction interface on the PointBufferTool class.  The code for the class should appear as follows:

删除PointBufferTool的构造函数,然后继承ImapServerToolAction接口了,类的代码应该如下所示:

[C#]

public class PointBufferTool : IMapServerToolAction

{

    public void ServerAction(ToolEventArgs args) {  }

}

7>>Inside the ServerAction method (Sub), insert code to get a reference to the Map control from the ToolEventArgs.Control property. This and the remainder of the code in the tutorial should be placed before the close of the method (for C#, before the first of the two closing braces; for VB, before the End Sub).

添加一个ServerAction的方法,并且添加一些代码从ToolEventArgsde的控件属性里面获取一个MapControl接口。这个以及教程里面剩余的代码都应该在方法的结束之前添加进入。

(对于C#来说:放在后面的一个大括号的前面,对于VB来说:放到End Sub 前面)

ESRI.ArcGIS.ADF.Web.UI.WebControls.Map mapctrl;

mapctrl = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control;

>>>>8

Since the ClientAction for the tool will be set to "Point", cast the ToolEventArgs to MapPointEventArgs and get the point (mouse click) provided

by the end-user in map coordinates.  This point will be added to the ArcGIS Server data source as custom graphics. 

因为工具在客户端的动作将会被设置为点,将ToolEventArgs 转换为MapPointEventArgs并且获取用户在地图坐标上单击的点。这个点将被作为一个自定义几何要素添加到ArcGISSeever的数据源里面。

//

>>>9

MapPointEventArgs mpea = (MapPointEventArgs)args;

Since we're going to add custom graphics to the map generated by ArcGIS Server, we need to get the Web ADF functionality associated with drawing map images.  When a Map control consumes a resource, it generates a MapFunctionality, one for each resource.  As a result, a Map control can have an array of MapFunctionalities.  In this tutorial, there is only one resource, and ArcGIS Server resource.  To get the MapFunctionality associated with a map resource item, use the resource item name (in this case "MapResourceItem0").   Since we know it is a type of ArcGIS Server resource, we can cast the functionality to the ArcGIS Server specific MapFunctionality.  We'll need to do this to work with ArcGIS Server specific implementation classes to draw graphics and work with server context.

因为我们要将一个有ArcGISsERVER创建的一个用户自定义几何要素添加到地图上。 我们需要获取一个和在地图上画图有相关的Web ADF功能。当一个用户控件消耗了一个资源,她就胡产生一个地图功能,每一个资源一个。结果是,地图控件就会有一些列的地图功能。在这个教程里面,这里仅仅有一个资源,是一个ArcGISServer资源。为了获取和一个地图资源相关的地图功能,使用资源项的名称(在这里我们使用MapResourceIems0)。因为我们知道她是一种ArcGISSerever类型的资源,我们可以将这个功能转换为ArcGISServer某种特定的功能。我们将使用rcGIS Server特定的实现类来完成这个功能,画一个图形,并同ServerContext一起工作

原文地址:https://www.cnblogs.com/xingchen/p/1789967.html