Error code 500 at REST Endpoint of published geoprocessing service perhaps due to out

المشرف العام

Administrator
طاقم الإدارة
Using ArcGIS 10.1 (Server and Desktop) I've been trying to publish a geoprocessing service based on a python script I wrote. Of course, it all works flawlessly from ArcGIS Desktop but I run into all sorts of problems when publishing.

I'm pretty sure the problem is related to the types of my output parameters or something to that effect. Here's the python script, minus comments and messages to GUI...

import arcpyimport jsonimport sysimport osfrom arcpy import envclass Result(object): passout = Result();arcpy.env.overwriteOutput = Trueconfig = arcpy.GetParameterAsText(0) # A string containing a path to a JSON config filesource = arcpy.GetParameter(1) # A string containing the name of a layersWhere = arcpy.GetParameter(2) # A String containig a where clausedistan = arcpy.GetParameter(3) # A String containing a distance linear unittarget = arcpy.GetParameter(4) # An Array containing multiple layer namestry: f = open(config) try: jsonCfg = json.load(f) finally: f.close()except: pass# jsonCfg['connection'] is a path to an SDE connection fc = os.path.join(jsonCfg['connection'], source)scratch = os.path.abspath(jsonCfg['scratch'])arcpy.MakeFeatureLayer_management(fc,"source_lyr")arcpy.SelectLayerByAttribute_management("source_lyr", "NEW_SELECTION", sWhere)bufLyrNam = os.path.join(scratch, "source_buf")arcpy.Buffer_analysis("source_lyr", bufLyrNam, distan)buffer = arcpy.FeatureSet()buffer.load(bufLyrNam)nLayers = len(target)selection = []for i in range(0, nLayers): lyrNam = "target_lyr_" + str(i); tgtNam = os.path.join(jsonCfg['connection'], target) arcpy.MakeFeatureLayer_management(tgtNam, lyrNam) arcpy.SelectLayerByLocation_management(lyrNam, "INTERSECT", bufLyrNam) cpyNam = os.path.join(scratch, target.replace(".","")) arcpy.CopyFeatures_management(lyrNam, cpyNam) fs = arcpy.FeatureSet() fs.load(cpyNam) selection.append(fs)out.selection = selectionarcpy.SetParameter(5, out)At first, I wanted to output the "out" object but apparently, this is not allowed in geoprocessing services. I can still publish the service but the output is converted to an unusable string.

I then tried to output only the "buffer" variable (containing a featureset) using an output parameter of type Any Value, Feature Class, Feature Layer... etc. and tried to output the selection variable as a Multiple Value Feature Class with no success.

In fact, something weird happens when I try to output the buffer. Once my service is published, I cannot access its REST endpoint, I always get a error code 500 page. This leaves me thinking that the arcpy.SetParameter must correspond to the output parameter type in order to even access the REST endpoint.

I've been working on this for a couple of days and I'm out of ideas which is why I created an account and asked my question. Can anyone help me figure out the problem here?



أكثر...
 
أعلى