Select to view content in your preferred language

Unable to execute custom GP Tool hosted in ArccGIS Server 10.2

3416
3
10-23-2013 10:34 AM
Labels (1)
JohnPtasznik
Emerging Contributor
I am working on creating a custom GP Tool in C#.
I have created the tool and registered it for Desktop and it runs as expected.
I then registered the tool on Server and published the result from desktop.
From Desktop I am able to execute the published server tool and it works as expected.
Calling the same server tool from the WPF Runtime 10.1.1 results in the following error:
Error code '400': 'Unable to complete operation.'
the input is not a geographic or projected coordinate system

This error makes no sense to me because:

            var spatialReference = new SpatialReference("GCS_North_American_1983"); //4269
            //var spatialReference = new SpatialReference(4269);
            var call = new FeatureSet
            {
                GeometryType = GeometryType.Point,
                SpatialReference = spatialReference
            };
            call.Features.Add(new Graphic { Geometry = new MapPoint(-122.1869709520000000, 47.6350545160001000, spatialReference) });

            Geoprocessor geoprocessorTask = new Geoprocessor("http://localhost:6080/arcgis/rest/services/CalculateProximity4/GPServer/Calculate%20Proximity");


            geoprocessorTask.OutputSpatialReference = spatialReference;
            geoprocessorTask.ProcessSpatialReference = spatialReference;
            var param1 = new GPRecordSet("input_call_point", call);
            param1.FeatureSet.SpatialReference = spatialReference;
            var param2 = new GPRecordSet("input_units_features", _units);
            param2.FeatureSet.SpatialReference = spatialReference;
            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(param1);
            parameters.Add(param2);



I seem to be setting the spatial reference on every possible location I see.

I have a model that I used to create a gpk for doing local routing that passes the same types of parameters with the exact same code that works either as a local package or as a GP Service hosted in ArcGIS Server 10.2. The only difference I see between those services definition is this:

For the routing task that works I see this as the definition of the parameter on the server:
Parameter: Stops
Data Type: GPFeatureRecordSetLayer
Display Name Stops
Description: Point to Point Routing
Direction: esriGPParameterDirectionInput
Default Value:
Geometry Type: esriGeometryPoint
HasZ: false
HasM: false
Spatial Reference: 4269  (4269)

Fields:
OBJECTID ( type: esriFieldTypeOID , alias: OBJECTID )
Features: None.

For the Custom GP Tool I see this, which has no spatial reference.
Parameters:
Parameter: input_call_point
Data Type: GPFeatureRecordSetLayer
Display Name Input Call
Description: call
Direction: esriGPParameterDirectionInput
Default Value:
Geometry Type:
HasZ: false
HasM: false
Spatial Reference: N/A
Fields: None

Features: None.


I have looked all over and can not find a way in my C# code to set the spatial reference on the default value for my parameters. 
All the examples I see do the exact same thing I do.
                IGPParameterEdit3 inputParameter = new GPParameterClass();
                inputParameter.DataType = new GPFeatureRecordSetLayerType() as IGPDataType;
                inputParameter.Value = defaultRSLayer as IGPValue;
                inputParameter.Direction = esriGPParameterDirection.esriGPParameterDirectionInput;
                inputParameter.DisplayName = "Input Call";                                
                inputParameter.Name = "input_call_point";
                inputParameter.Domain = (IGPDomain)fcDomain;                
                inputParameter.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
                parameters.Add(inputParameter);



I am really at a loss as to how to create a default value with a spatial reference set.   I would really rather not have to set the spatial reference for the default value, but that is all I see as different between the service that works from my model and my custom GP tool.

Thanks in Advance,
John
0 Kudos
3 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

Have you tried submitting the "input_call_point" parameter as a GPFeatureRecordSetLayer? GPRecordset represents a nonspatial table of records, whilst GPFeatureRecordSetLayer represents a set of spatial records. I suspect that when GPRecordSet is converted to JSON to be sent as part of the request, there's no spatial reference included - you can confirm this by checking the requests in Fiddler (other network monitoring tools are available).

Cheers

Mike
0 Kudos
JohnPtasznik
Emerging Contributor
I tried changing the parameter as suggested and the same error occurs.
How do I configure fiddler to capture messages to ArcGIS Server 10.2?
I have ArcGIS Server 10.2 running on my development box on the default port 6080, but can't figure out how to capture the traffic.

Thanks,
John
0 Kudos
JohnPtasznik
Emerging Contributor
So I was correct on what the issue is.
I had the same problem with a Geoprocessing Package based on an ArcPy tool.  Once I added the schema which had a spatial reference it worked.  I just need to figure out how to add the schema to my custom GP Tool.
0 Kudos