Select to view content in your preferred language

Internal Server Error 500  executing ArcPy GPK

1181
5
11-05-2013 06:55 AM
JohnPtasznik
Emerging Contributor
I have created an ArcPy GP Function based on a model I built.
I can execute it in Desktop and it behaves as expected.
I publish the package and when I run my program against it I get the following exception:

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request
)
   at System.Net.WebClient.DownloadString(Uri address)
   at ESRI.ArcGIS.Client.Tasks.TaskBase.Request(String url, Dictionary`2 parameters, Boolean forcePost)
   at ESRI.ArcGIS.Client.Tasks.Geoprocessor.Execute(List`1 parameters)
   at RoutingWithGeoProcesingPackage.Program.RunTool(Geoprocessor gpTask) in c:\Code\CAD\Prototypes\GIS\RoutingWithGeoProcesingPackage\RoutingWithGeoProcesingPackage\Program.cs:line 112
   at RoutingWithGeoProcesingPackage.Program.Main() in c:\Code\CAD\Prototypes\GIS\RoutingWithGeoProcesingPackage\RoutingWithGeoProcesingPackage\Program.cs:line 48

Here is the code:
# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("Network")

# Script arguments
Stops = arcpy.GetParameterAsText(0)

Barriers = arcpy.GetParameterAsText(1)

Impedance_Attribute = arcpy.GetParameterAsText(3)
if Impedance_Attribute == '#' or not Impedance_Attribute:
    Impedance_Attribute = "Time" # provide a default value if unspecified

Restrictions = arcpy.GetParameterAsText(4)
if Restrictions == '#' or not Restrictions:
    Restrictions = "Oneway" # provide a default value if unspecified

Vehicle_Weight = arcpy.GetParameterAsText(5)

Vehicle_Height = arcpy.GetParameterAsText(6)

Directions_XML_File = arcpy.GetParameterAsText(7)

# Local variables:
Input_Network_Dataset = "C:\\ServerData\\GCSRouting.gdb\\NetworkDataset_Data\\Streets_ND"
Route = "SolvedRoute"

# Process: Make Route Layer
arcpy.MakeRouteLayer_na(Input_Network_Dataset, Route, Impedance_Attribute, "USE_INPUT_ORDER", "PRESERVE_BOTH", "NO_TIMEWINDOWS", "", "ALLOW_UTURNS", Restrictions, "NO_HIERARCHY", "", "TRUE_LINES_WITH_MEASURES", "")

# Process: Add Vehicle Weight
if Vehicle_Weight:
 arcpy.UpdateAnalysisLayerAttributeParameter_na(Route, "WeightRestrtiction", "Vehicle Weight", Vehicle_Weight)

# Process: Add Vehicle Height
if Vehicle_Height:
 arcpy.UpdateAnalysisLayerAttributeParameter_na(Route, "HeightRestriction", "Vehicle Height", Vehicle_Height)

# Process: Add Stops
arcpy.AddLocations_na(Route, "Stops", Stops, "", "5000 Meters", "", "Driveways SHAPE;Streets SHAPE;Driveway_Endpoints SHAPE;Streets_ND_Junctions NONE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "Driveways #;Streets #;Driveway_Endpoints #;Streets_ND_Junctions #")

# Process: Add Barriers
if Barriers:
 arcpy.AddLocations_na(Route, "Point Barriers", Barriers,"", "5000 Meters", "", "Driveways SHAPE;Streets SHAPE;Driveway_Endpoints SHAPE;Streets_ND_Junctions NONE", "MATCH_TO_CLOSEST", "CLEAR", "NO_SNAP", "5 Meters", "INCLUDE", "Driveways #;Streets #;Driveway_Endpoints #;Streets_ND_Junctions #")

# Process: Directions
arcpy.env.workspace = "in_memory"
if Directions_XML_File == '#' or not Directions_XML_File:
    Directions_XML_File = arcpy.CreateUniqueName("Directions.xml", arcpy.env.scratchFolder)

arcpy.AddMessage("Directions XML = " + Directions_XML_File)
arcpy.Directions_na(Route, "XML", Directions_XML_File, "Miles", "REPORT_TIME", "Time", "en", "NA Desktop")
#, "")

# Process: Select Data
SelectResults = arcpy.SelectData_management(Route, "Routes")
SelectLayer = SelectResults.getOutput(0)

OutFeatureSet = arcpy.FeatureSet()
OutFeatureSet.load(SelectLayer)
arcpy.SetParameter(2, OutFeatureSet)
arcpy.SetParameter(7, Directions_XML_File)


Any ideas?

Thanks,
John
0 Kudos
5 Replies
BKuiper
Frequent Contributor
Have you considered running Fiddler to see what is being pushed back and forward ? that might give you some insight in what is going wrong.

http://fiddler2.com/
0 Kudos
JohnPtasznik
Emerging Contributor
I have not had any success configuring fiddler with ArcGIS Server 10.2.  Any clues as to how to do that?
I have it running on the same box as this and it uses the default port of 6080.  No matter what I do I can't see any messages from the console WPF application and the ArcGIS Server service.
0 Kudos
BKuiper
Frequent Contributor
Not sure about 10.2, but in 10.1.1 you will need to use the Local Server Utility that is installed and accessible through the Start button. This has an option to enable HTTP debugging of .NET client applications.
0 Kudos
RichardWatson
Deactivated User
0 Kudos
JohnPtasznik
Emerging Contributor
Thank you for the help.  I forgot about the debug option on the local server.
0 Kudos