Select to view content in your preferred language

Sending string to custom GP Service in a silverlight app

905
3
03-02-2012 04:12 AM
justinperez
Deactivated User
I have a custom gp service that is writing to a text file.  If I paste this http://mywebsite.com/ArcGIS/rest/services/Geoprocessing/gpServiceTest/GPServer/gpService/submitJob?I...! into the browser, my gp service works.  I can't figure out the syntax needed to send this through c#.

Here is what I have:
SUBMITGEOMETRY is a constant string in the Densify class
Densify.SUMBITGEOMETRY = "http://gis.mustangeng.com/ArcGIS/rest/services/Geoprocessing/gpServiceTest/GPServer/gpService/submit..."

Uri serviceUri = new Uri(Densify.SUBMITGEOMETRY);
string s = "?Input=" + String.Join(",", dictElevat.Keys.Select(o => o.ToString()).ToArray());
webClient1.UploadStringAsync(serviceUri, "POST", s);

Here is the rest page of my gp service

{
  "name" : "gpService",
  "displayName" : "gpService",
  "category" : "",
  "helpUrl" : "http://myhostmachine/arcgisoutput/Geoprocessing_gpServiceTest/TestFuncs.htm",
  "executionType" : "esriExecutionTypeAsynchronous",
  "parameters" : [
    {
      "name" : "Input",
      "dataType" : "GPString",
      "displayName" : "Input",
      "direction" : "esriGPParameterDirectionInput",
      "defaultValue" : "This is a test in ArcMap!",
      "parameterType" : "esriGPParameterTypeRequired",
      "category" : "",
      "choiceList" : []
    }
  ]
}


Thanks.
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
Once you have clientaccesspolicy in place, the code looks like this:

You can subscribe to StatusUpdated and\or JobCompleted to see JobInfo. GPString need to include the parameter name "Input" and the value, in this case the string you want to write to file.
   var geoprocessorTask = new Geoprocessor("http://gis.mustangeng.com/ArcGIS/rest/services/Geoprocessing/gpServiceTest/GPServer/gpService");
   geoprocessorTask.StatusUpdated += (s, e) =>
    {
     MessageBox.Show(string.Format("StatusUpdated \nID: {0}\nStatus: {1}", e.JobInfo.JobId, e.JobInfo.JobStatus));
    };
   geoprocessorTask.JobCompleted += (s, e) =>
    {
     MessageBox.Show(string.Format("JobCompleted \nID: {0}\nStatus: {1}", e.JobInfo.JobId, e.JobInfo.JobStatus));
    };
   var gpParameters = new List<GPParameter>();
   gpParameters.Add(new GPString("Input", "http://mywebsite.com/ArcGIS/rest/services/Geoprocessing/gpServiceTest/GPServer/gpService/submitJob?Input=WOWee"));
   geoprocessorTask.SubmitJobAsync(gpParameters);
0 Kudos
justinperez
Deactivated User
Thanks a bunch!  Do you know where this is documented?  The GPParameter piece specifically.  I'm using some of the code samples from the silverlight api with this but

So the Geoprocessor is a delegate?  Is this documented somewhere?  Thanks again!  (Premature thanks..hope I don't have to return)
0 Kudos
markcheyne
Deactivated User
As far as documentation goes, I learned what I needed from the 'Geoprocessing' node of the samples at http://help.arcgis.com/en/webapi/silverlight/samples/start.htm, and the API Reference at http://help.arcgis.com/en/webapi/silverlight/apiref/api_start.htm for the Geoprocessor class under ESRI.ArcGIS.Client.Tasks
0 Kudos