How to Use ArcGIS Javascript API with IBM worklight - Proxy setting issue

3804
1
02-25-2015 01:33 AM
ShashankKatte
New Contributor

Hi,

 

Trying to create a hybrid mobile application using IBM worklight and ArcGIS Kavascript APIs. We are trying to create a simple navigation app using ArcGIS.

 

While using navigation widget from ArcGIS we are facing problem with proxy setup. Is proxy setup mandatory?

 

The code is as follows

<script src="http://js.arcgis.com/3.12/"></script>

    <script>

      require([

        "esri/urlUtils", "esri/map", "esri/dijit/Directions",

        "dojo/parser",

        "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"

      ], function(

        urlUtils, Map, Directions,

        parser

      ) {

        parser.parse();

      

     

     

        //all requests to route.arcgis.com will proxy to the proxyUrl defined in this object.

        urlUtils.addProxyRule({

          urlPrefix: "http://route.arcgis.com",

          proxyUrl: "http://192.168.4.109:10080/ProxyServer/proxy.js"

        });

        urlUtils.addProxyRule({

          urlPrefix: "http://traffic.arcgis.com",

          proxyUrl: "http://192.168.4.109:10080/ProxyServer/proxy.js"

       

        });

 

 

  var url = urlUtils.arcgisUrl;

        url= url.replace("file:", "http:");

        urlUtils.arcgisUrl = url;

     

        var map = new Map("map", {

          basemap: "streets",

          center:[-98.56,39.82],

          zoom: 4

        });

 

 

 

 

        var directions = new Directions({

          map: map

        },"dir");

        directions.startup();

      });

    </script>

 

we get error message:

Route service description was not reached or recognized. Please check service URL and OR user credential

02-25 15:01:08.604: I/chromium(17307): [INFO:CONSOLE(192)] "RequestError: Unable to load file://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World?f=json status: 0", source: http://js.arcgis.com/3.12/init.js (192)

 

Need help to resolve this issue.

0 Kudos
1 Reply
BjornSvensson
Esri Regular Contributor

First, I'm not familiar with IBM worklight....

As for the routing, no a proxy is not needed, but if you don't use it, the users of your application would be prompted to log in.

You can test/see this in action by deleting the "urlUtils.addProxyRule" from this sandbox sample  or or this sandbox sample.

0 Kudos