ServiceException -- Unable to complete operation

3806
8
09-20-2011 09:12 PM
JudyTroutwine
Occasional Contributor
I am testing a simple bare bones Geoprocessing project and keep getting the
ESRI.ArcGIS.Client.Tasks.ServiceException error.  The model is as simple as can be -- just one string parameter.  What could be the issue?  Here is the code:

The XAML:

<UserControl x:Class="GPpoint.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009"        
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="StartMarkerSymbol" Color="Red" 
                  Style="Triangle" Size="8" />
            <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#99FF9999" BorderBrush="#FFFF9999" BorderThickness="2"  />
        </Grid.Resources>

        <esri:Map x:Name="MyMap" Background="White" MouseClick="MyMap_MouseClick">
            <esri:Map.Extent >
                <esri:Envelope XMin="846500" YMin="982350" XMax="850600" YMax="986500" >
                    <esri:Envelope.SpatialReference>
                        <esri:SpatialReference WKID="2256"/>
                    </esri:Envelope.SpatialReference>
                </esri:Envelope>
            </esri:Map.Extent>

            <esri:ArcGISDynamicMapServiceLayer ID="CampAb"
                     Url=myURL/>
        </esri:Map>

    </Grid>
</UserControl>

The code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Geometry;
using ESRI.ArcGIS.Client.Tasks;
using ESRI.ArcGIS.Client.Symbols;

namespace GPpoint
{
    public partial class MainPage : UserControl
    {
        Geoprocessor _geoprocessorTask;

        public MainPage()
        {
            InitializeComponent();
            _geoprocessorTask = new Geoprocessor(http://myserver/arcgis/rest/services/GPServer/GPTest/GPServer);
            _geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted;
            _geoprocessorTask.Failed += GeoprocessorTask_Failed;
            _geoprocessorTask.UpdateDelay = 5000;
            _geoprocessorTask.GetInputCompleted +=GeoprocessorTask_GetInputCompleted;
            _geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted;
            _geoprocessorTask.GetResultDataCompleted +=GeoprocessorTask_GetResultDataCompleted;
            _geoprocessorTask.StatusUpdated +=GeoprocessorTask_StatusUpdated;
        }

        private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e)
        {
            _geoprocessorTask.CancelAsync();


            MyMap.Cursor = System.Windows.Input.Cursors.Wait;
            String pname = "strValue";
            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(new GPString("inputValue",pname));

           _geoprocessorTask.OutputSpatialReference = new SpatialReference(2256);
           _geoprocessorTask.ExecuteAsync(parameters);

        }

        private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args)
        {
           MessageBox.Show("ExecuteCompleted");
            MyMap.Cursor = System.Windows.Input.Cursors.Hand;
        }

        private void GeoprocessorTask_GetInputCompleted(object sender, GPParameterEventArgs e)  //not raised
        {
            MessageBox.Show("GetInputCompleted");
        }   

        private void GeoprocessorTask_StatusUpdated(object sender, JobInfoEventArgs e)   //not raised
        {
            MessageBox.Show("StatusUpdated");
            MessageBox.Show(e.JobInfo.JobId.ToString());             
            MessageBox.Show(e.JobInfo.JobStatus.ToString());                    
        }

        private void GeoprocessorTask_Failed(object sender, TaskFailedEventArgs e)  //raised
        {
            MyMap.Cursor = System.Windows.Input.Cursors.IBeam;
            MessageBox.Show("Geoprocessor service failed: " + e.Error);
        }
    }
}
0 Kudos
8 Replies
DominiqueBroux
Esri Frequent Contributor
_geoprocessorTask = new Geoprocessor(http://myserver/arcgis/rest/services...est/GPServer);


Not sure if it's a mistake in the post or in your code, but the name of your GP tool is missing at the end of the Url.
Should be something like:
 
_geoprocessorTask = new Geoprocessor("http://myserver/arcgis/rest/services...est/GPServer/MyTool");
 
0 Kudos
JudyTroutwine
Occasional Contributor
That does seem to be a part of the problem.  Now there is a message that the task does not exist or is inaccessible.  Pasting the URL in a web browser shows the appropriate information about the task. 

Does it matter whether the tool is published as toolbox or as a toollayer in a map?  I tried both ways with the same problem.  What is odd is that the toolbox GPServices listed in ArcCatalog are not expandable to show the individual tools.  I pubished the ArcTutor DriveTimePolygonsService for comparison -- same issue.  Ideas please.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Is the execution mode of your task 'Synchronous' or 'Asynchronous' ?

If your task is asynchronous, you have to use SubmitJobAsync to execute the task.

Could you share the informations about your task? This could give ideas about the issue.
0 Kudos
JudyTroutwine
Occasional Contributor
Yes, thank you, I did see info about the asynchronous aspect on the rest/services page for the task and began using the SubmitJobAsync approach. 

The model "FolderTest" in toolbox "Folder1" has one tool, Create Folder with one string parameter to name the folder.  The tool works well when added as a tool layer in ArcMap.

When published, using http://agsdev/ArcGIS/Manager/Help/index.html#/GP_service_example_Drive_time_polygons/00930000003z000...

as an example. Intending to test the the tool service in ArcMap, I found that the tool service is not expandable in the ArcCatalog listing of the tool service.  Ditto for the drive time polygons sample, e.g, the Calculate Drive Times Polygons tool also is not visible in the GIS Servers tree in ArcCatalog even though the DriveTimesPolygonsService containing the tool seemed to publish normally.

The more complete URL for the task service is :
           _geoprocessorTask = new Geoprocessor("http://myserver/arcgis/rest/services/GPServer/FolderT1/GPServer/FolderTest");
            _geoprocessorTask.JobCompleted += GeoprocessorTask_JobCompleted;
            _geoprocessorTask.Failed += GeoprocessorTask_Failed;

One parameter is passed in a string variable:

            String fname = "Folder1";
            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(new GPString("String",fname));
       
           _geoprocessorTask.OutputSpatialReference = new SpatialReference(2256);
         //  _geoprocessorTask.ExecuteAsync(parameters);
          _geoprocessorTask.SubmitJobAsync(parameters);


The fact that the tool can be added as a tool layer but not as a GIS Server tool service to ArcMap is perhaps a clue.  The published toolboxes are visible in the GIS Servers tree in ArcCatalog but not the tools within the toolboxes.  If a tools is not visible in the ArcCatalog listing, that might be why I am getting a message that the tool is inaccessible.  I hope that it is not necessary to reinstall all of ArcGIS.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
_geoprocessorTask = new Geoprocessor("http://myserver/arcgis/rest/services/GPServer/FolderT1/GPServer/FolderTest");


I am still not sure it's the right Url.

If you execute the Url in your browser, you should get the infos about your tool.
Something like : http://serverapps.esri.com/ArcGIS/rest/services/SamplesNET/USA_Data_ClipTools/GPServer/ClipCounties

What do you get in your case?
0 Kudos
JudyTroutwine
Occasional Contributor
I copied the browser page here (and changed the server name to "myserver").  There are no feature layers in the model, only the Create Folder tool.

------------------------------------------------------------------------------

Task: FolderTest
Display Name: FolderTest

Category:

Help URL: http://myserver/arcgisoutput/GPServer_FolderT1/Model2222.htm

Execution Type: esriExecutionTypeAsynchronous

Parameters:


Parameter: Value

Data Type: GPString
Display Name: Value
Direction: esriGPParameterDirectionInput
Default Value: UMArbFolder
Parameter Type: esriGPParameterTypeRequired
Category:



Supported Operations:   Submit Job

Supported Interfaces:   REST
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Your parameter is called 'Value'.

So your code should be : parameters.Add(new GPString("Value",fname)); instead of : parameters.Add(new GPString("String",fname));
0 Kudos
JudyTroutwine
Occasional Contributor
Aha, that works!  Thanks much.
0 Kudos