Toolbox as geoprocessing service

259
2
10-03-2012 09:10 AM
NadeemQazi
New Contributor III
I have created a toolbox using a Model builder and than using ARCGIS server Manager published this on the server as geoprocessing service. the URL of the service is :
http://na-lap-3z8/ArcGIS_server/services/Toolboxes_Lesson1/GPServer

Now I wish to access this service using the python. I used following code:
arcpy.ImportToolbox("http://na-lap-3z8/ArcGIS_server/rest/services;Toolboxes_Lesson1","abc")

however i received the following error:
Runtime error <type 'exceptions.ValueError'>: Error opening Toolbox.

The folder where this toolbox is shared and can be seen from the ARCGIS manager. Any clue what is wrong in my code or what should i do to access this GP service.
Regards
Nadeem
0 Kudos
2 Replies
KevinHibma
Esri Regular Contributor
0 Kudos
NadeemQazi
New Contributor III
You're close.

Try this:
arcpy.ImportToolbox("http://na-lap-3z8/ArcGIS_server/services;Toolboxes_Lesson1","abc")

Also see this for more info: http://resources.arcgis.com/en/help/main/10.1/index.html#/Using_a_geoprocessing_service_in_Python_sc...


thanx it worked for me . however when i run following code:I can see status return by the server is 4 and also in the result window of the arcmap i can see a file is created. however when result1.getOutput(0) fails showing the following  error:
Runtime error <type 'exceptions.RuntimeError'>: ResultObject: Error in getting output

my code is:
result1= arcpy.abc.suitablelandfromparammodel(cities,"5 miles","5 miles",boundry,roads)
while result1.status <4:
print result1.status
time.sleep(0.2)
print "execution finished"
result1.getMessages()
arcpy.CopyFeatures_management(result1.getOutput(0),'localresult.shp')

any idea what is reason
regards
nadeem
0 Kudos