Select to view content in your preferred language

Geoprocessing tasks in Flex

991
7
08-11-2010 09:32 AM
AronHarris
Emerging Contributor
Does anyone have sample code for doing a Geoprocessing tasks. I have the server side done its just the Flex part I am stuck on like how to call and display it.
Tags (2)
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus
Aron,

   Have you not seen the GP samples like http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=GP_Viewshed ?
0 Kudos
AronHarris
Emerging Contributor
Aron,

   Have you not seen the GP samples like http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=GP_Viewshed ?


I have looked at it and played with it. I am having a problem with displaying it back on the map.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Aron,

    Just because you have the GP setup and working in desktop does not mean that you have all the parameters setup correctly for the GP to be published and usable as a service in server. There are some very specific step you have to take for a GP to be ready to publish to server. I cover the steps for start to finish in the thread.

http://forums.esri.com/Thread.asp?c=158&f=2421&t=285944&mc=7
0 Kudos
AronHarris
Emerging Contributor
Aron,

    Just because you have the GP setup and working in desktop does not mean that you have all the parameters setup correctly for the GP to be published and usable as a service in server. There are some very specific step you have to take for a GP to be ready to publish to server. I cover the steps for start to finish in the thread.

http://forums.esri.com/Thread.asp?c=158&f=2421&t=285944&mc=7


Hi Robert,

I did your step by step example which is very nice. I am getting this error (RPC Fault faultString="" faultCode="400" faultDetail="GPTask 'execute' does not exist or is inaccessible). Any idea on what I am missing
0 Kudos
DasaPaddock
Esri Regular Contributor
What is the execution type? If it is "esriExecutionTypeAsynchronous" like this one, then you'll need to call submitJob instead of execute.

http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/Incident_Data_Extraction...

Reference:
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/tasks/Geoprocessor.html
0 Kudos
AronHarris
Emerging Contributor
What is the execution type? If it is "esriExecutionTypeAsynchronous" like this one, then you'll need to call submitJob instead of execute.

http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/Incident_Data_Extraction...

Reference:
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/tasks/Geoprocessor.html


I am doing it step-by-step outline in Robert Scheitlin

  GP_Service_Steps2.txt (opens in new window)
its syncronus

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:esri="http://www.esri.com/2008/ags"
    pageTitle="Count ADTs"
    layout="absolute">

    <mx:Script>
        <![CDATA[
            import com.esri.ags.Graphic;
            import com.esri.ags.events.MapMouseEvent;
            import com.esri.ags.geometry.MapPoint;
            import com.esri.ags.tasks.ExecuteResult;
            import com.esri.ags.tasks.FeatureSet;
            import com.esri.ags.tasks.ParameterValue;
      import com.esri.ags.geometry.Polygon;
            import mx.controls.Alert;
            import mx.rpc.AsyncResponder;
           
     private function GetCount():void
  {
  var pPnt:MapPoint = new MapPoint(myMap.extent.xmin, myMap.extent.ymin);
             var pPnt2:MapPoint = new MapPoint(myMap.extent.xmax, myMap.extent.ymin);
             var pPnt3:MapPoint = new MapPoint(myMap.extent.xmax, myMap.extent.ymax);
             var pPnt4:MapPoint = new MapPoint(myMap.extent.xmin, myMap.extent.ymax);
             var pPoly:Polygon = new Polygon();
             pPoly.addRing([pPnt, pPnt2, pPnt3, pPnt4, pPnt]);
            
             var gra:Graphic = new Graphic(pPoly);
            
             var featureSet:FeatureSet = new FeatureSet([gra]);

                var params:Object = {
                    "sf123_shp":featureSet
                };
                gp.execute(params); //,  new  AsyncResponder(onResult, onFault)
                function onResult(gpResult:ExecuteResult = null, token:Object = null):void
                {
                 var pv:ParameterValue = gpResult.parameterValues[0];
                 Alert.show(pv.value.toString());
                }
                function onFault(info:Object, token:Object = null):void
                {
                    Alert.show(info.toString());
                    graphicsLayer.clear();
                }
     }
        ]]>
    </mx:Script>

    <mx:Button x="0" y="0" label="Get Count" click="GetCount()"/>
    <esri:Map id="myMap" zoomSliderVisible="false" height="537" y="21">
        <esri:ArcGISDynamicMapServiceLayer
                     url="http://stangis/ArcGIS/rest/services/Maps/test1/MapServer"/>
        <esri:GraphicsLayer id="graphicsLayer"/>
</esri:Map>
    <esri:Geoprocessor
        id="gp"
        url="http://stangis/ArcGIS/rest/services/GP/gpTest1/GPServer"
        showBusyCursor="true"/>
</mx:Application>
0 Kudos
DasaPaddock
Esri Regular Contributor
The url looks like it's too short. It should be to the task.
0 Kudos