Select to view content in your preferred language

How do you reference the proxy.ashx page?

19364
25
08-09-2011 09:26 AM
MatthewGerbrandt
New Contributor II
Hello there. I've got some secured ArcGIS Services that require a token.  I've got my proxy.ashx and proxy.config pages in place and configured.

The last thing I need to do is figure out how to get my JS/HTML pages to reference those proxy pages and pass the token to the services.

If someone could please post some code or point me to an example, I'd be tremendously grateful.  The info at http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jshelp_start.htm#jshelp/... wasn't helpful because my pages don't have a code-behind page for the C# code.

Thanks a million in advance!!
0 Kudos
25 Replies
MatthewGerbrandt
New Contributor II
Also, is this an externally facing server?  If so, do you have a reverse proxy set up?


Yes to both of those.

Disabled the requirement for SSL, by the way.  I can now generate a token that's supposed to be good for 10 days.  The problem is that the tokens being generated that way don't work.  They're very long tokens and maybe that's the problem(?).

The only tokens that work are the ones generated the following way:
1) I go to the URL of one of the restricted services (http://Server.Name2.com/ArcGIS/rest/services/cadaster/AboriginalUseArea/MapServer).
2) I click on the link for viewing the ArcGIS JavaScript map.
3) I go to "View Source" and find the token that gets generated.
0 Kudos
MatthewGerbrandt
New Contributor II
Saurabh -

Is there any chance that you or someone at ESRI could check out this problem with your remote desktop tools?  I've experimented with every possible combination of proxy.config settings using server names and IP addresses.  The manually generated tokens and the proxy pages are not working. 

I'm completely stumped and I really need the ability to display secured services in web maps.  If there's anything you can do to help me, I'd sure appreciate it.  Thanks a lot!
0 Kudos
by Anonymous User
Not applicable
If you're still having problems and need to contact Support the number is 888-377-4575 or you can use the Online My Support tools.

http://support.esri.com/en/

Regards,
Doug Carroll, ESRI Support Services SDK Team
http://support.esri.com/
0 Kudos
MatthewGerbrandt
New Contributor II
Thank you, Doug.  I already have an open ticket for this issue. Saurabh has been working on it.
0 Kudos
HaroldBostic
Occasional Contributor II
Hello, please ensure you are using the ip address that you get when ping'ing from outside your internal network.  Ping your Server.Name.com url from outside your network.

If you try that and it still does not work, and ESRI does not help, let me know and I'll contact you offline.

Good Luck
0 Kudos
MatthewGerbrandt
New Contributor II
With help from Thang at ESRI, I was able to solve this problem.  The first thing I had to do was to add a line of code to my web page:

<script type="text/javascript">
    dojo.require("esri.map");
    dojo.require("dijit.layout.ContentPane");
    dojo.require("dijit.layout.BorderContainer");
    var map;
    function Init() {

        esri.config.defaults.io.alwaysUseProxy = true;
        esri.config.defaults.io.proxyUrl = "http://WebServerName/proxy.ashx"; 
        dojo.style(dojo.byId("map"), { width: dojo.contentBox("map").w + "px", height: (esri.documentBox.h - dojo.contentBox("navTable").h - 40) + "px" });
        map = new esri.Map("map");
        
        var CountyDataLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://Server.Name/ArcGIS/rest/services/Counties/MapServer");
        map.addLayer(CountyDataLayer);

        var RestrictedLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://Server.Name/ArcGIS/rest/services/cadaster/ServiceName/MapServer");
        map.addLayer(RestrictedLayer);
        
        
        var resizeTimer;
        dojo.connect(map, 'onLoad', function(theMap) {
            dojo.connect(dijit.byId('map'), 'resize', function() {
                clearTimeout(resizeTimer);
                resizeTimer = setTimeout(function() {
                    map.resize();
                    map.reposition();
                }, 500);
            });
        });
    }
    dojo.addOnLoad(Init);
</script>


... and I used the following code in my proxy.config file:

<?xml version="1.0" encoding="utf-8" ?>
<!-- Proxy config is used to set the ArcGIS Server services that the proxy will forward to.        
        mustMatch: true to only proxy to sites listed, false to proxy to any site -->
<ProxyConfig mustMatch="true">
 <serverItems>
  
  <serverItem url="http://Server.Name"
     matchAll="true" tokenUrl="http://Server.Name/ArcGIS/tokens"
     username="MyUserName" password="MyPassword"
     timeout="5" />

 </serverItems>
</ProxyConfig>
0 Kudos