Select to view content in your preferred language

Geoprocessing problem - javascript + REST

844
6
11-18-2011 06:00 AM
MarijaSmoljanic
Deactivated User
Hello,

I have a problem consuming a geoprocessing service with Extract Data task using javascript API and REST on ArcGIS Server 10.

When consumed from a web app the service returns feature classes with no data. However, when consumed from ArcMap (also as a service) everything works fine.

The task always finishes successfully.

I modified the code from the javascript API samples page, and here it is:

        var clipLayers = [];
        if(dijit.byId('layer1').checked){clipLayers.push('TACKE_EM');}
        if(dijit.byId('layer2').checked){clipLayers.push('LINIJE_EM');}
        if(dijit.byId('layer3').checked){clipLayers.push('POVRSINE_EM');}
        if(clipLayers.length === 0 || map.graphics.graphics.length === 0){
          alert('Select layers to extract and area of interest');
          return;
        }
        var features =[];
        features.push(map.graphics.graphics[0]);
        var featureSet = new esri.tasks.FeatureSet();
        featureSet.features = features;

     var rasterFormat = "ESRI GRID - GRID";
     var spatialReference = "MGI Balkans 7";

        var params = {"Layers_to_Clip":clipLayers,
          "Area_of_Interest": featureSet,
          "Feature_Format": dijit.byId('formatBox').value,
          "Raster_Format" : rasterFormat,
          "Spatial_Reference" : spatialReference
        };
       
        gp.submitJob(params, completeCallback , statusCallback,function(error){
          alert(error);
        });

What am I doing wrong?
If you need additional info, please ask.

Thanks in advance.
0 Kudos
6 Replies
HemingZhu
Frequent Contributor
Hello,

I have a problem consuming a geoprocessing service with Extract Data task using javascript API and REST on ArcGIS Server 10.

When consumed from a web app the service returns feature classes with no data. However, when consumed from ArcMap (also as a service) everything works fine.

The task always finishes successfully.

I modified the code from the javascript API samples page, and here it is:

        var clipLayers = [];
        if(dijit.byId('layer1').checked){clipLayers.push('TACKE_EM');}
        if(dijit.byId('layer2').checked){clipLayers.push('LINIJE_EM');}
        if(dijit.byId('layer3').checked){clipLayers.push('POVRSINE_EM');}
        if(clipLayers.length === 0 || map.graphics.graphics.length === 0){
          alert('Select layers to extract and area of interest');
          return;
        }
        var features =[];
        features.push(map.graphics.graphics[0]);
        var featureSet = new esri.tasks.FeatureSet();
        featureSet.features = features;

     var rasterFormat = "ESRI GRID - GRID";
     var spatialReference = "MGI Balkans 7";

        var params = {"Layers_to_Clip":clipLayers,
          "Area_of_Interest": featureSet,
          "Feature_Format": dijit.byId('formatBox').value,
          "Raster_Format" : rasterFormat,
          "Spatial_Reference" : spatialReference
        };
       
        gp.submitJob(params, completeCallback , statusCallback,function(error){
          alert(error);
        });

What am I doing wrong?
If you need additional info, please ask.

Thanks in advance.


To consume a GP service result, you need either put the result layer on a map service or put it in scratch workspace (the AGS server will store it in job output folder identified by job id). Which approach did you take?
0 Kudos
MarijaSmoljanic
Deactivated User
The result is saved in ArcGIS server jobs folder, and I can download it. However, the downloaded featrue classes contain no features when the gp service is called via REST. The same input parameters for the gp service result in not empty feature classes when called via SOAP.
0 Kudos
HemingZhu
Frequent Contributor
The result is saved in ArcGIS server jobs folder, and I can download it. However, the downloaded featrue classes contain no features when the gp service is called via REST. The same input parameters for the gp service result in not empty feature classes when called via SOAP.


Have you tested via REST through service directory (put JSON text for AOI etc)?
0 Kudos
MarijaSmoljanic
Deactivated User
hzhu, thanks for the suggestion.
Just tried it, and the service returns not empty feature classes.
What could I be doing wrong in my code?
0 Kudos
HemingZhu
Frequent Contributor
hzhu, thanks for the suggestion.
Just tried it, and the service returns not empty feature classes.
What could I be doing wrong in my code?


Without knowing your GP service, i can't pinpoint what is wrong with your code. My guess is most likely your parameter setting.
0 Kudos
MarijaSmoljanic
Deactivated User
Thank you for your suggestions. I will test my parameters in more detail.
0 Kudos