Map service是最常见的ArcGIS service,可以拥有很多能力和功能。Map service本身具备mapping和map viewing的能力,也可以支持modeling和geoprocessing,mobile GIS services以及OGC WMS, OGC WCS, KML的能力。
要发布map service,首先得在ArcMap中准备一个map document (.mxd)。将这个mxd文件发布成map service后,便可通过服务访问该地图文档的数据,显示图层,并使用该地图内建的任何能力。也可以选择对这个服务建立cache,使其能够更快速的被浏览。
创建map document
必须使用ArcGIS Desktop来创建map document。
创建准备发布成服务的map document的一些技巧
需要合理安排地图文档的内容,范围,标注,注记等等要素,将它们安排到合理的位置,切记不要太繁琐,同时考虑到地图的美观性。
发布service
我是用ArcCatalog进行发布的,所以只说使用ArcCatalog发布的方法。
- In the Catalog tree, navigate to the resource you want to publish. For example, navigate to a map document on disk.
- Right-click the resource and click Publish to ArcGIS Server.
- Choose which server you want to publish the resource to, type a name for the service, then choose the folder in which the service will reside. Click Next.
- Choose the capabilities you would like to enable for the resource and click Next. Different types of resources expose different types of capabilities.
-
Review the information about the service that will be created. If you will be working with the service through the Web, take special note of the service's URL. You can't enter this URL in a browser directly, but you can enter the URL and append ?wsdl to see the service's Web service definition and verify that the service is working correctly.
Note that multiple Web service endpoints can be created when you specify certain capabilities (for example, the KML capability for map services creates an additional endpoint suffixed KmlServer in addition to the default map service).
启动ArcCatalog——双击Add Arcgis Server —— 选择Manage Gis Server —— 下一步 —— 输入Host Name —— 右键新建的GIS Server —— Add new server —— 一路Next就可以了
以下是图解
启用service中的相应能力
发布一个map service后,通过启用相应的能力可以创建其他与map service一起工作的service。其中一些能力要求地图文档包含有特定的图层。
下表中列出了map service拥有的能力,和启用相应能力的要求。
发布好服务,就可以访问自己的服务了。但是打开预览后,并没有出现我们所希望看到的地图,那么我们添加InitializationFailed属性,跟踪错误。
代码如下:相关详细内容点击这里
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<UserControl x:Class="APIforSilverlightSamp.s2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ESRI="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
mc:Ignorable="d">
<Grid x:Name="LayoutRoot" Background="White">
<ESRI:Map x:Name="mymap">
<ESRI:Map.Layers>
<ESRI:ArcGISDynamicMapServiceLayer InitializationFailed="ArcGISDynamicMapServiceLayer_InitializationFailed" Url="http://junyuzhang/ArcGIS/rest/services/myMapService/MapServer"/>
</ESRI:Map.Layers>
</ESRI:Map>
</Grid>
</UserControl>
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace APIforSilverlightSamp
{
public partial class s2 : UserControl
{
public s2()
{
InitializeComponent();
}
private void ArcGISDynamicMapServiceLayer_InitializationFailed(object sender, EventArgs e)
{
ESRI.ArcGIS.Client.Layer layer = sender as ESRI.ArcGIS.Client.Layer;
MessageBox.Show(layer.InitializationFailure.ToString());
}
}
}
出现如下提示:
经过查证,是跨域访问的问题,在根目录下缺少 clientaccesspolicy.xml 和 crossdomain.xml 这两个文件
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
把他们放入C:\Inetpub\wwwroot目录下,然后再预览一次。OK,可以正常访问了
学习资料来源:http://webhelp.esri.com/arcgisserver/9.3/dotNet/index.htm#map_service.htm
http://www.cnblogs.com/SunYu/archive/2010/04/30/1724714.html
http://webhelp.esri.com/arcgisserver/9.3/dotNet/index.htm#what_can_you_publish.htm