Select to view content in your preferred language

Secure Service won't display in JavaScript

752
2
06-06-2011 07:48 AM
JacobRaymond
Deactivated User
I have a map service that I am messing around with here (Secure service): https://teramaps.teraenv.com/ArcGIS/rest/services/AppliedMethod/APP_Carto_Parks_Protected_Areas/MapS...

^^ Right click and copy link, as clicking on that won't work ^^

If I paste that entire link into my browser I can get to it no problem, if I use that link in a Flex application it displays no problem.  If I try to access that link in Javascript it will not display. Has anyone ever experienced this?  Am I missing something obvious here?

Any input is appreciated.

Thanks,

Jacob

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
  <title>ArcGIS JavaScript API: AppliedMethod/APP_Carto_Grids</title>
  <link href='https://community.esri.com/ArcGIS/rest/ESRI.ArcGIS.Rest.css' rel='stylesheet' type='text/css'>
<style type="text/css">
  @import "https://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css";
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
      .tundra .dijitSplitContainer-dijitContentPane, .tundra .dijitBorderContainer-dijitContentPane#navtable { 
        PADDING-BOTTOM: 5px; MARGIN: 0px 0px 3px; PADDING-TOP: 0px; BORDER-BOTTOM: #000 1px solid; BORDER-TOP: #000 1px solid; BACKGROUND-COLOR: #E5EFF7;
      }
      .tundra .dijitSplitContainer-dijitContentPane, .tundra .dijitBorderContainer-dijitContentPane#map {
        overflow:hidden; border:solid 1px black; padding: 0;
      }
      #breadcrumbs {
        PADDING-RIGHT: 0px; PADDING-LEFT: 11px; FONT-SIZE: 0.8em; FONT-WEIGHT: bold; PADDING-BOTTOM: 5px; MARGIN: 0px 0px 3px; PADDING-TOP: 0px;
      }
      #help {
        PADDING-RIGHT: 11px; PADDING-LEFT: 0px; FONT-SIZE: 0.70em; PADDING-BOTTOM: 5px; MARGIN: 0px 0px 3px; PADDING-TOP: 3px; 
</style>
<script type="text/javascript" src="https://serverapi.arcgisonline.com/jsapi/arcgis?v=2.0"></script>
<script type="text/javascript">
  dojo.require("esri.map");
  dojo.require("dijit.layout.ContentPane");
  dojo.require("dijit.layout.BorderContainer");
  var map;
  function Init() {
    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 layer = new esri.layers.ArcGISDynamicMapServiceLayer("https://teramaps.teraenv.com/ArcGIS/rest/services/AppliedMethod/APP_Carto_Parks_Protected_Areas/MapServer?token=ItX80paTB9xhPfhupRMGCMJ27tNS8ocuOpI22h_G09yZioox-jopFTlw3QLuojqNOYbwolt-T6Mi0ek-YMYzyg..");
    map.addLayer(layer);
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>
</head>
<body class="tundra">
<table style="width:100%">
<tr>
<td>
<table id="navTable" width="100%">
<tbody>
<tr valign="top">
<td id="breadcrumbs">
ArcGIS JavaScript API: AppliedMethod/APP_Carto_Grids
</td>
<td align="right" id="help">
Built using the  <a href="https://resources.esri.com/arcgisserver/apis/javascript/arcgis">ArcGIS JavaScript API</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<div id="map" style="margin:auto;width:97%;border:1px solid #000;"></div>
</body>
</html>
 
0 Kudos
2 Replies
HemingZhu
Frequent Contributor
I have a map service that I am messing around with here (Secure service): https://teramaps.teraenv.com/ArcGIS/rest/services/AppliedMethod/APP_Carto_Parks_Protected_Areas/MapS...

^^ Right click and copy link, as clicking on that won't work ^^

If I paste that entire link into my browser I can get to it no problem, if I use that link in a Flex application it displays no problem.  If I try to access that link in Javascript it will not display. Has anyone ever experienced this?  Am I missing something obvious here?

Any input is appreciated.

Thanks,

Jacob

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
  <title>ArcGIS JavaScript API: AppliedMethod/APP_Carto_Grids</title>
  <link href='https://community.esri.com/ArcGIS/rest/ESRI.ArcGIS.Rest.css' rel='stylesheet' type='text/css'>
<style type="text/css">
  @import "https://serverapi.arcgisonline.com/jsapi/arcgis/2.0/js/dojo/dijit/themes/tundra/tundra.css";
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
      .tundra .dijitSplitContainer-dijitContentPane, .tundra .dijitBorderContainer-dijitContentPane#navtable { 
        PADDING-BOTTOM: 5px; MARGIN: 0px 0px 3px; PADDING-TOP: 0px; BORDER-BOTTOM: #000 1px solid; BORDER-TOP: #000 1px solid; BACKGROUND-COLOR: #E5EFF7;
      }
      .tundra .dijitSplitContainer-dijitContentPane, .tundra .dijitBorderContainer-dijitContentPane#map {
        overflow:hidden; border:solid 1px black; padding: 0;
      }
      #breadcrumbs {
        PADDING-RIGHT: 0px; PADDING-LEFT: 11px; FONT-SIZE: 0.8em; FONT-WEIGHT: bold; PADDING-BOTTOM: 5px; MARGIN: 0px 0px 3px; PADDING-TOP: 0px;
      }
      #help {
        PADDING-RIGHT: 11px; PADDING-LEFT: 0px; FONT-SIZE: 0.70em; PADDING-BOTTOM: 5px; MARGIN: 0px 0px 3px; PADDING-TOP: 3px; 
</style>
<script type="text/javascript" src="https://serverapi.arcgisonline.com/jsapi/arcgis?v=2.0"></script>
<script type="text/javascript">
  dojo.require("esri.map");
  dojo.require("dijit.layout.ContentPane");
  dojo.require("dijit.layout.BorderContainer");
  var map;
  function Init() {
    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 layer = new esri.layers.ArcGISDynamicMapServiceLayer("https://teramaps.teraenv.com/ArcGIS/rest/services/AppliedMethod/APP_Carto_Parks_Protected_Areas/MapServer?token=ItX80paTB9xhPfhupRMGCMJ27tNS8ocuOpI22h_G09yZioox-jopFTlw3QLuojqNOYbwolt-T6Mi0ek-YMYzyg..");
    map.addLayer(layer);
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>
</head>
<body class="tundra">
<table style="width:100%">
<tr>
<td>
<table id="navTable" width="100%">
<tbody>
<tr valign="top">
<td id="breadcrumbs">
ArcGIS JavaScript API: AppliedMethod/APP_Carto_Grids
</td>
<td align="right" id="help">
Built using the  <a href="https://resources.esri.com/arcgisserver/apis/javascript/arcgis">ArcGIS JavaScript API</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<div id="map" style="margin:auto;width:97%;border:1px solid #000;"></div>
</body>
</html>
 


Does the token associate with your credential (jraymond)? When i clicked the Supported Interfaces:   REST. I got this error:

{
  "error" :
  {
    "code" : 499,
    "message" : "Unauthorized access",
    "details" : []
  }
}

If you use the IIS, you can put an impersonate to test the page using your credential:
<identity impersonate="true" userName="yourdomain\jraymond " password=password/>
0 Kudos
JacobRaymond
Deactivated User
Problem solved, I wasn't generating the token properly.  For whatever reason the flex app didn't seem to care, but the JavaScript app did.

Thank-you hzhu, your comments prompted me to look closer at the tokens.

JR
0 Kudos