WSDOT-GIS / CIA-Local-Roads-Selector

A sample application that calls secure routing services.
The Unlicense
0 stars 0 forks source link

accessing ArcGIS Server secure services #2

Closed bibeputt closed 10 years ago

bibeputt commented 11 years ago

I am trying to test this solution with ArcGIS server 10.1 secured service but even after getting a token , no map is being displayed.

JeffJacobson commented 11 years ago

If you are using a secure map service, you'll need to add it to the proxy.config file.

bibeputt commented 11 years ago

Yes i made an entry into proxy.config like:

serverUrl url="http://xxx.xxx.com/Mygis/rest/services/secVector/MapServer" matchAll="true" dynamicToken="true"

and changed index.js as:

require(["require", "dojo/dom", "dojo/on", "esri/urlUtils", "esri/map", "esri/layers/GraphicsLayer",
    "esri/tasks/locator", "esri/tasks/RouteTask", "esri/renderers/SimpleRenderer",
    "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/graphic", "esri/InfoTemplate",
    "esri/dijit/Basemap", "esri/dijit/BasemapLayer",  "esri/layers/ArcGISTiledMapServiceLayer",
    "dojo/_base/connect",
    "esri/dijit/Attribution"],
    function (require, dom, on, urlUtils, Map, GraphicsLayer, Locator, RouteTask, SimpleRenderer, SimpleMarkerSymbol,
        SimpleLineSymbol, Graphic, InfoTemplate, Basemap, BasemapLayer, ArcGISTiledMapServiceLayer, connect) {
        "use strict";
        var map, protocol;

        protocol = window.location.protocol;

        urlUtils.addProxyRule({
            proxyUrl: "proxy.ashx",
            urlPrefix: "http://xxx.xxx.com"
        });

        map = new esri.Map("map");
        map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://xxx.xxx.com/Mygis/rest/services/secVector/MapServer", { id: "Vector" }), 0);

    });

I can see the generated token as well as map service metadata but cannot see any map in browser.

JeffJacobson commented 11 years ago

I'm not sure what the cause of the issue is. Since it may be a while until I have a chance to look at this project again, I posted your issue to the ArcGIS.com forums.

You also may want to check out the proxy page in this project: Esri/map-and-app-gallery.

jgravois commented 11 years ago

its not enough to ask for a dynamicToken to be generated for you. if you are trying to use the proxy to access a secure resource, you'll need to hard-code a long-term token in the proxy config instead.

then you should test whether the proxy is authenticating appropriately for the secure resource outside your app entirely. (ie. http://server/proxy.ashx?http://server/arcgis/rest/secure/MapServer). if this displays the map service details, the resource should be returned in your app as well.