ArcServer10.2 使用JavaScript API实现地图服务限制访问及跨域问题的解决

来源:互联网 发布:淘宝买家vip等级 编辑:程序博客网 时间:2024/05/18 01:32

为了保证地图服务只能经身份认证的用户才能访问,从而保证用户的安全性,为地图服务设置了用户访问权限。

为了系统调用地图服务时,能够更方便的进行访问,决定引入proxy.ashx,其代码及配置详情,可参考其他帖子,不再赘述。

总结经验,主要需注意以下细节:

proxy.config需配置为以下格式:

<?xml version="1.0" encoding="utf-8" ?>
<ProxyConfig allowedReferers="*"
             mustMatch="true">
    <serverUrls>
        <serverUrl url ="http://192.168.94.247:6080/arcgis/rest/services"
               matchAll="true"
               dynamicToken="true"
         username="username"
               password="password"
               host="192.168.94.247:6080"/>
    </serverUrls>
</ProxyConfig>


javascript(采用3.14的API)需配置如下:


            esriConfig.defaults.io.proxyUrl = "http://localhost:81/proxy.ashx";
            esriConfig.defaults.io.alwaysUseProxy = true;
            esriConfig.defaults.io.corsDetection = false;
            esriConfig.defaults.io.corsEnabledServers.push("192.168.94.247:6080");//这行代码为了解决'Access-Control-Allow-Origin'的问题


注意:proxy是配置在IIS下的,网上有配置在Java下的,但是唯有成功,可参考其他的帖子学习http://blog.csdn.net/wpz0713/article/details/50245041。

0 0
原创粉丝点击