Run Geo-processing Service

223
3
Jump to solution
11-27-2017 03:03 PM
MohammadrezaNikfal1
Occasional Contributor

HI, I am trying to run a very simple python tool as Geo-processing Service. As usual I created the tool as follows:

import arcpy

inputLong = float(arcpy.GetParameterAsText(0))
inputLat = float(arcpy.GetParameterAsText(1))
xy = [(inputLat, inputLong)]

fc = r"Database Connections\Connection to XXX-XXXXX.sde\A.DBO.CropPoint"
cursor = arcpy.da.InsertCursor(fc, ["SHAPE@XY"])
for row in xy:
    cursor.insertRow([row])
del cursor

and shared as Geo-processing Service on my ArcGIS server. On JavaScript I wrote the code as  follows:

            var gpUrl = "http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer";

            var gp = new Geoprocessor(gpUrl);

                            var params1 = {
                                Longitude: -101.55,
                                Latitude: 35.6
                            };
                            gp.submitJob(params1);
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

It does not work (i.e. does not add point to my point map), however I can directly run it in the "ArcGIS REST Services Directory" on my browser. Also I tried "gp.execute(params1)" to run the tool.

0 Kudos
1 Solution

Accepted Solutions
MohammadrezaNikfal1
Occasional Contributor

Found the problem. The rest URL is :

http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer

Bu in the code you should use the complete url (that you can find " ArcGIS REST Services Directory" in the browser) as follows:

http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer/Script%201

View solution in original post

0 Kudos
3 Replies
tyleraustin1
New Contributor

Mohammadreza,

When you published the geoprocessing service did you publish it as a synchronous or asynchronous service? This will help determine if you run execute or sumbitJob.

Second, when publishing the service what input types were selected for the parameters?

Best, - Tyler 

0 Kudos
MohammadrezaNikfal1
Occasional Contributor

Hello

I tried with both execute and submit job correctly.

The parameters are Double

Thanks

0 Kudos
MohammadrezaNikfal1
Occasional Contributor

Found the problem. The rest URL is :

http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer

Bu in the code you should use the complete url (that you can find " ArcGIS REST Services Directory" in the browser) as follows:

http://XXX-XXXXX:6080/arcgis/rest/services/Script2/GPServer/Script%201

View solution in original post

0 Kudos