Consuming geoprocessor service from ActionScript

2427
11
01-16-2012 08:23 AM
by Anonymous User
Not applicable
Original User: tarekesri

Hello,
I'm using ArcGIS API for flex. I'm trying to consume a geoprocessing service developed with Arcgismanager interface. The service works fine when I use the url of its task (see "task_GP_service" figure). When I try to execute it with ActionScript code it doesn't work (see the ActionScript code figure).

Thanks for your help,

Tarek
0 Kudos
11 Replies
by Anonymous User
Not applicable
Original User: ibespalov

Tarak,

Some ESRI documentation for you: concepts, reference, and samples with source code.

Seems like geoprocessor task input params are not valid.

var params:Object = new Object();
params.in_features = "C:\Donnees\Adriatic\Adriatic.gdb\Situation_Geo\Sites_archeo";
params.buffer_distance_or_field = { "distance" : 2.678, "units" : "esriMiles" };
gp.execute(params);
0 Kudos
TarakSbouai
New Contributor
Ivan, I still don't get any result (in Task directory) as I get it from the rest interface (see first figure in my first thread).

Here is the new code :
..
private var in_features:String;
private var buffer_distance_or_field:LinearUnit;
  
private function executer():void
{
  var params:Object = new Object();
  params.in_features = "C:\Donnees\Adriatic\Adriatic.gdb\Situation_Geo\Sites_archeo";
  params.buffer_distance_or_field = { "distance" : 2.678, "units" : "esriMiles" };
   
  gp.submitJob(params); // since it's an asynchronous task
}

Thanks,

Tarek
0 Kudos
by Anonymous User
Not applicable
Original User: rscheitlin

Tarek,

   Your distance parameter is still not correct.

import com.esri.ags.Units;
import com.esri.ags.tasks.supportClasses.LinearUnit;

params.buffer_distance_or_field = new LinearUnit(2.678, Units.MILES);
0 Kudos
TarakSbouai
New Contributor
Robert,
There is no error in the code. However, when I execute it from Flash Builder (even with the modifications you suggested), I still get no output. I assume the output layer of the buffer operation should be in the arcgisjobs (the output of the GP server defined with ArcGIS Server manager).
Another thing; tha service task url contains space, do you think that causes a problem? see code in attached figure.

Thanks,
Tarek
0 Kudos
by Anonymous User
Not applicable
Original User: ibespalov

From ArcGIS server help - Publishing geoprocessing services:
"...The service name should not contain spaces..."


[ATTACH=CONFIG]11217[/ATTACH]
0 Kudos
TarakSbouai
New Contributor
Ivan, I used another GP service with Erase task (called Effacer) so the url won't contain any space. However, I still don't get any result (I still get an output when I use the rest interface (see figures)).

Thanks,
Tarek
0 Kudos
by Anonymous User
Not applicable
Original User: ibespalov

Tarak,
it's just some kind of magic.

Please read help provided by Flex API developers. Geoprocessor task has some number of public properties. You must configure it before using.


Anyway, if you have more questions, please paste code with Geoprocessor task public properties, result listener, fault listener.

Good luck.

P.S. here is sample. Take a look on GP properties, job complete listener and fault listener.

You can try to examine you requests / server responses using developer tools. Some time it helps to find wrong request parameter. You can also compare requests you made from FLEX application and requests you send from ArcGIS services directory.

In IE browser - F12 (developer tools) -> Network tab -> Start capturing.

In Chrome browser - F12 (developer tools) -> Network tab

In FF browser - Firebug

Also Fiddler from MSDN
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tarak,

  To add to what Ivan is saying you need to understand that just because a GP service works in ArcMap does not gaurnetee it working as a published service. There are many things you have to do to make your GP Service a published GP service.

Look at this link and search for info on scratchworkspace as you should be using that.

http://help.arcgis.com/en/arcgisserver/10.0/help/arcgis_server_dotnet_help/index.html#/Key_concepts_...
0 Kudos
by Anonymous User
Not applicable
Original User: tarekesri

Robert, my GP service does work as a published service. But only within rest interface. Its does not work when I try to consume it within an ActionScript application.

Thanks Ivan & Robert,
Tarek
0 Kudos