Select to view content in your preferred language

GP Service run from python (secure) Issue

2156
3
07-01-2013 06:49 PM
ShaunWeston
Frequent Contributor
I've setup a python script to a run a geoprocessing service e.g.

http://resources.arcgis.com/en/help/main/10.1/index.html#//00570000004w000000

All works well for unsecure service, but when securing the service, I can't get it to work. The syntax for the tool in python I use is:


http://server/arcgis/services;Tools/DataUpdate;user;password

And the error I get:


<DataUpdateFromZip_DataUpdate> not found
Completed script DataUpload...

Then if I switch back to unsecure service I still get that error, but if I publish it as an unsecure service and leave it that way it works fine.

Any ideas?
Tags (2)
0 Kudos
3 Replies
LindseyWood
Deactivated User
The link you have provided for the password example seems to be broken can you re paste it?  Not sure with the information but switching from http to https does require a different python class to link to. 
http://resources.arcgis.com/en/help/main/10.1/index.html#//015400000600000000
class urllib2.HTTPHandler

    A class to handle opening of HTTP URLs.

class urllib2.HTTPSHandler

    A class to handle opening of HTTPS URLs.
http://docs.python.org/2/library/urllib2.html

But again not sure what you are using....
0 Kudos
KevinHibma
Esri Regular Contributor
Based on the syntax you posted, I assume you're trying to consume the GP service in the "arcpy" way?
You're passing user/password via the ImportToolbox arcpy command?

Based on your comments it behaves differently depending on how you publish (secure vs non-secure), and the error - it sounds like your virtual directories might not be right? Which could be an HTTP vs HTTPS issue.

Taking Python out of it, can you make a connection in ArcMap to your secure server (with a USER connection), and consume the service and get back a result. It looks like your result is a Zip file, so you'll have to open the Results window, expand the execution and double click the output to open the Zip.
0 Kudos
ShaunWeston
Frequent Contributor
Whoops I didn't see I got some replies. Thanks for the responses.

Yes I'm trying to consume a GP service using arcpy and trying to add username/password to the ImportToolbox command, but it's not working, however it works fine for unsecure services.

This works...
        arcpy.ImportToolbox("http://servername/arcgis/services;Tools/DataUpdate", "toolbox")
        arcpy.DataUpdateFromZip_toolbox("Existing")  


This doesn't...
        arcpy.ImportToolbox("http://servername/arcgis/services;Tools/DataUpdate;username;password", "toolbox")
        arcpy.DataUpdateFromZip_toolbox("Existing")  

Error - Object: Tool or environment <DataUpdateFromZip_DataUpdate> not found


Yes I can execute the tool (secured) through ArcCatalog

Yeah it might be something to do with http/https. I'm not sure exactly how that's meant to work. Https isn't enabled on this server.
0 Kudos