gmahase

ArcGISs REST service + DOJO Servicestore issue

Discussion created by gmahase on Apr 22, 2010
I'm having an issue getting information from an ARCGIS REST service using a dojo service store. The store is created successfully, and I can query the search part of it from a custom .NET RPC Webservice. But when I try to do a query on an ESRI REST service it gives me an error.
The error I'm recieving is:
Unable to load <URL> status: 0

The URL is the correct URL that corresponds to a query layer REST service with the correct querystring parameters. Anyone have any experience with this?

SMD File

{
    SMDVersion:"2.0",
    contentType:"application/json",

    services: {
        Search: {
     transport: "POST",
     envelope: "JSON-RPC-2.0",
     target: "/services/testRpc.ashx?rpc",
            parameters: [
                {name:"search", optional: false},
                {name:"start", optional: true},
                {name:"count", optional: true}
            ]
        },
        query: {
     transport: "GET",
     envelope: "URL",
          target: "http://arcserver/ArcGIS/rest/services/Development/test/MapServer/0/query",
            parameters: [
    {name:"where", optional: false},
    {name:"returnGeometry", optional: false, "default":"true"},
    {name:"outFields", optional: false, "default":"loc_code"},
    {name:"f", optional: false, "default":"pjson"}
            ]
        }
    }
}


ServiceStore

dojo.declare("doe.data.myStore", dojox.data.ServiceStore,
{
    constructor: function()
    {
        console.log("myStoreconstructor");
        svc = new dojox.rpc.Service("/SchoolRpc.smd");
        this.service = svc.search;
        this.idAttribute = "a";
        this.labelAttribute = "b";
    },
    fetch: function(/* object */ request)
    {
        console.log("myStore fetch");
        var rq = dojo.mixin({}, request.query);
  if (rq && (!rq.action || rq.action === "search"))
  {
   this.service = svc.search;
   rq.search = request.query.search;
   rq.start = request.start;
   rq.count = request.count;  
  }
  else if (rq.action === "load")
  {
   this.service = svc.query;
   rq.where = "id='" + rq.id + "'";
   rq.returnGeometry = "true";
   rq.outFields = "id";
   rq.f = "pjson";
   delete rq.id;
   delete rq.action;
  }
  request.query = rq; 
        return this.inherited(arguments);       
    },
    _processResults: function(results, def)
    {
        console.log("myStore _processResults",results.total);       
        this._totalResults = results.total
  return results;
    },
    _totalResults:0,
_svc:null
});


JS Code for Fetching data

request = store.fetch({
                    query:{ action:"load",id:"29" }
                });

Outcomes