Engine如何加载ArcGIS Server发布的地图服务?

Engine如何加载ArcGIS Server发布的地图服务?
已邀请:

朱新颖

赞同来自: minokie

【解决办法】:
两种方式:
1,可以通过遍历的方式,根据地图服务的名称进行判断,然后加载。
2,Engine 10.1及之后版本的话可以使用IMapServerRESTLayer加载,测试代码:

 
IAGSServerObjectName pSOName = null; 
IAGSServerObjectName psoname = null; 
IAGSServerConnection con = new AGSServerConnection(); 
IAGSServerConnectionFactory2 confactory = new AGSServerConnectionFactory() as IAGSServerConnectionFactory2; 
IPropertySet propertyset = new PropertySet(); 
IMapServerLayer mapserverlayer = new MapServerLayerClass(); 

propertyset.SetProperty(URL, http://192.168.220.116:6080/arcgis/rest/services); 

con = confactory.Open(propertyset, 0); 

IAGSEnumServerObjectName enumSOName = con.ServerObjectNames; 

pSOName = enumSOName.Next(); 
while (pSOName != null) 

if (pSOName.Name == MyMapService1) 

psoname = pSOName; 
break; 

pSOName = enumSOName.Next(); 

IName pName = psoname as IName; 
IMapServer mapserver = pName.Open() as IMapServer; 

mapserverlayer.ServerConnect(pSOName, mapserver.DefaultMapName); 
axMapControl1.AddLayer(mapserverlayer as ILayer); 
axMapControl1.Refresh(); 




IMapServerRESTLayer mapServerRESTLayer = new MapServerRESTLayerClass();
mapServerRESTLayer.Connect(http://localhost:6080/arcgis/r ... Server);

axMapControl1.AddLayer(mapServerRESTLayer as ILayer);
axMapControl1.Refresh();

minokie

赞同来自:

追问:
我现有一个带了token 的arcgis 服务。 使用  IMapServerRESTLayer 接口加载到arcmap中。
使用 url +"?token="  连接并没有成功。
使用fiddler查看了请求地址, 发现其中http referer 是 "http://www.esri.com/xxxxxxxxx"
而服务的token是我们自定义的一个http referer标识,比如 "http://www.myhost.com"
那么,使用IMapServerRESTLayer 加载带token 的arcgis server rest服务时,如何能够更改他默认的 referer ?
 

要回复问题请先登录注册