Hi there,
I have setup a geoprocessing task (a python script) that generates a PDF based on a map document "template". The script takes a number of arguments, including map extent, SR, visible layers, etc. (the script is actually the "Export PDF web application and GP service sample" from David Spriggs).
When I run this from ArcCatalog (as a tool) and enter some values, the tool runs and the PDF is created at my specified location on the local disk. However, when I access and run this very same task from my JSPAI application, it simply returns the error: "Error Submitting Job" (the error stack just points to the JSAPI - using v2.2).
I have setup a proxy and this seems to work fine (I get a 200 status) when submitting the task. The parameters are definitely correct, as I have written them to the console, then copied and pasted them in the tool dialog (via ArcCatalog) and the tool runs fine.
To test further, I used the SubmitJob page through the rest service directory. Again, I entered all the values and the results come back saying the task is complete. However, the PDF created is not located in the directory specified in the python script, but at some non-existent location (http://<server>/arcgisjobs/exportpdf_gpserver/j07d98f158f774503be941bcccedce974/scratch/Map_test6.pdf).
So, is it that the GP task ignores the file paths of the original script and uses a setting of its own to save the new file? If so, where is that setting? Or is that just a temp path used by the rest service interface? Or am I totally confused?
Any help or suggestions welcome.
Thanks,
Richard.
P.S. It also might be worth noting that the GP error I get comes back very fast. When the tool runs successfully from arccatalog it can take up to a minute. So I am assuming the problem is "early" in the task (i.e. connection, variables, etc.) rather than in the task itself.
var params = { "xMin": map.extent.xmin, "yMin": map.extent.ymin, "xMax": map.extent.xmax, "yMax": map.extent.ymax, "Spatial_Reference": map.spatialReference.wkid, "Map_Scale": esri.geometry.getScale(map), "Visiblelayers": dojo.toJson(visiblelayers), "Layout": dijit.byId("mapLayout").value, "Include_Attributes": dijit.byId("incAttribs").checked, "Map_Title": dijit.byId("mapTitle").value, "PointGraphics": getFeatureSet("point"), // optional "LineGraphics": getFeatureSet("polyline"), // optional "PolyGraphics": getFeatureSet("polygon") // optional }; console.log("PDF PARAMETERS"); console.log(map.extent.xmin); console.log(map.extent.ymin); console.log(map.extent.xmax); console.log(map.extent.ymax); console.log(map.spatialReference.wkid); console.log(esri.geometry.getScale(map)); console.log(dojo.toJson(visiblelayers)); console.log(dijit.byId("mapLayout").value); console.log(dijit.byId("incAttribs").checked); console.log(dijit.byId("mapTitle").value); console.log(getFeatureSet("point")); console.log(getFeatureSet("polyline")); console.log(getFeatureSet("polygon"));
function pdfStatusCallback(jobInfo) { console.log(jobInfo.jobStatus); if (jobInfo.jobStatus === "esriJobFailed") { pdfErrorCallback(); } }
Hi..
Thanks for the info about the geoprocessor. Indeed, I can now see (and retrieve) the generated PDF when using the geoprocessing task through the services interface.
To test parameter input, I have written the exact values to the console (see code below), then copied and pasted them into the services interface - this is where I get a "esriJobSucceeded" status back.var params = { "xMin": map.extent.xmin, "yMin": map.extent.ymin, "xMax": map.extent.xmax, "yMax": map.extent.ymax, "Spatial_Reference": map.spatialReference.wkid, "Map_Scale": esri.geometry.getScale(map), "Visiblelayers": dojo.toJson(visiblelayers), "Layout": dijit.byId("mapLayout").value, "Include_Attributes": dijit.byId("incAttribs").checked, "Map_Title": dijit.byId("mapTitle").value, "PointGraphics": getFeatureSet("point"), // optional "LineGraphics": getFeatureSet("polyline"), // optional "PolyGraphics": getFeatureSet("polygon") // optional }; console.log("PDF PARAMETERS"); console.log(map.extent.xmin); console.log(map.extent.ymin); console.log(map.extent.xmax); console.log(map.extent.ymax); console.log(map.spatialReference.wkid); console.log(esri.geometry.getScale(map)); console.log(dojo.toJson(visiblelayers)); console.log(dijit.byId("mapLayout").value); console.log(dijit.byId("incAttribs").checked); console.log(dijit.byId("mapTitle").value); console.log(getFeatureSet("point")); console.log(getFeatureSet("polyline")); console.log(getFeatureSet("polygon"));
I do use the getResultData function, but before that even fires, I check the status using the statusCallback as follows:function pdfStatusCallback(jobInfo) { console.log(jobInfo.jobStatus); if (jobInfo.jobStatus === "esriJobFailed") { pdfErrorCallback(); } }
That console statement is never fired. So basically, the task is not even being sent to the service as expected (which would hint at a parameter issue like you say), but I cant see how since I am successfully using the same parameters using the services interface..
Still stumped!
Richard.