Asynchronous Geoprocessing Service Works with ArcExplorer, ArcMap, But Not JavaScript

2308
2
Jump to solution
06-25-2012 07:00 AM
chuckfrank
Occasional Contributor
Hi All,

I did the "GP Service Step By Step: Watershed Walkthrough" http://help.arcgis.com/en/arcgisserver/10.0/help/arcgis_server_dotnet_help/index.html#/GP_service_st... and successfully published an asynchronous geoprocessing service to create a watershed from a pour point.  Using ArcMap and ArcExplorer I was able to successfully connect and run to the geoprocessing service. 

Then I tried implementing it with the AGS JavaScript API, but whenever the job is submitted, almost immediately, I get an error "GP Task Create Watershed Polygon does not exist or is inaccessible".  Using Fiddler to see what happens, I can copy the URL and when I paste it into the browser I get this error "dojo.io.script.jsonp_dojoIoScript4._jsonpCallback({"error":{"code":500,"message":"GPTask 'Create Watershed Polygon' does not exist or is inaccessible.","details":[]}});"

Other geoprocessing services have worked for me, but they have been synchronous.  In the same location as the walkthrough above, I did the buffer features tutorial and everything worked great, but it was synchronous.  When I change the watershed service to synchronous, it times out. 

I feel like the problem must be in the syntax of possibly it's permissions.  I set up a proxy for it and am not really sure if that would be something that would cause a problem (worked for others).  Has anybody else been able to get the watershed walkthrough to work with the AGS Javascript API?  Does anybody have an idea of what could be wrong or how to troubleshoot this?

Here is a section of my code for the geoprocessor:

function computeWatershed(evt) {              map.graphics.clear();             var pointSymbol = new esri.symbol.SimpleMarkerSymbol();             pointSymbol.setOutline = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 1);             pointSymbol.setSize(5);             pointSymbol.setColor(new dojo.Color([0, 255, 0, 0.25]));              var graphic = new esri.Graphic(evt.mapPoint, pointSymbol);             map.graphics.add(graphic);              var features = [];             features.push(graphic);             var featureSet = new esri.tasks.FeatureSet();             featureSet.features = features;              var pourPoint = featureSet             var params = { "Pour_Point": featureSet };              gp = new esri.tasks.Geoprocessor("http://[server]/ArcGIS/rest/services/CreateWatershed/GPServer/Create%20Watershed%20Polygon");             gp.setOutputSpatialReference({ wkid: 102100 });             gp.updateDelay = 20000;             gp.submitJob(params, getCallback, getCallbackStatus, getError);  }   function getCallback() {             alert('getCallback');  }   function getCallbackStatus() {             alert('getCallbackStatus');  }  function getError(error) {             alert('GP Error: ' + error); } 
0 Kudos
1 Solution

Accepted Solutions
chuckfrank
Occasional Contributor
The reason it didn't exist or was inaccessible was because my parameter name was incorrect.  The actual parameter name is "PourPoint" not "Pour_Point"  Why that worked in ArcMap and ArcExplorer, I really don't know.  Maybe it reads the service more thoroughly.  Anyway, in the JavaScript API, if the parameter name is incorrect, it can cause this error.

View solution in original post

0 Kudos
2 Replies
chuckfrank
Occasional Contributor
The reason it didn't exist or was inaccessible was because my parameter name was incorrect.  The actual parameter name is "PourPoint" not "Pour_Point"  Why that worked in ArcMap and ArcExplorer, I really don't know.  Maybe it reads the service more thoroughly.  Anyway, in the JavaScript API, if the parameter name is incorrect, it can cause this error.
0 Kudos
nicogis
MVP Frequent Contributor
chuckf74, if you need low level arcobjects and you are interested I have made a same functionality with soe (I also have included js sample).

http://studioat.maps.arcgis.com/home/item.html?id=7b79eea8286e462bba9b2891b42d223a
http://nicogis.blogspot.it/2012/11/smack-bacini-idrografici.html

The only difference compared with gp is that soe take advantage of caching so it's fast compared with gp that it need cost of instance therefore if you service has low use gp is Ok
0 Kudos