Is there a GPDataFile input example for the Geoprocessing Widget - FV 3.3?

8000
5
09-03-2014 12:38 PM
GarySumners
New Contributor

I'm tackling the concept of creating a local GP service to convert a /local/ KML file to a viewable layer, then viewing the output layer in Flex Viewer (3.3 in use.)  I've currently got a GP service built and operating on our ArcGIS server, and it works correctly using ArcMap by way of accepting the input file and generating the output layer for display.  I can also generate the correct result by manually browsing to and using the GPDataFile input of the service.  If manually added, the resulting map service exists in the FV 3.3 instance.  Long story short, I've got the back-end part of this working.

What I'm looking for is a usage example for the ESRI Geoprocessing Widget, that uses the GPDataFile input parameter type.  The widget tags reference simply shows the existence of the parameter, and mentions that it should generate a dialog for file upload when used - when I change the GeoprocessingWidget.xml file to include the requisite taskurl/helpurl and the inputparams block, I end up with a 1009 error (null object reference) while the widget tries to initialize.  I don't get any dialog popup for selecting the source file.

I've verified spelling & case on all the references, and a different GP service I created for another instance of the Geoprocessing Widget does work, so I know this is at least partially an error in how I'm configuring the XML.

Here's a snippet showing how I'm configuring the input parameter:

    <inputparams>

        <param name="KMLInput"

               label="Input KML File"

               required="true"

               type="GPDataFile"

               visible="false">

        </param>

    </inputparams>

It's frustrating that the tag is referenced in the help, but there's not a usage example for it in the manner of the other input parameter types!

0 Kudos
5 Replies
ManikandanKalyanasundaram1
New Contributor II

Hi Gary,

ArcGIS server will not support direct GPDataFile upload. You have to upload the file using upload task and give the item id for the GP service.

Here is the high level idea to get it work for any GP service which needs file upload,

  • Publish the Geoprocessing service with upload option

Refer : ArcGIS Help (10.2, 10.2.1, and 10.2.2)

Operations allowed: Uploads: This capability controls whether a client can upload a file to your GIS server that the tasks within the geoprocessing service would eventually use. The upload operation is mainly used by web clients that need a way to send a file to the server for processing. The upload operation returns a unique ID for the file after the upload completes, which the web application could pass to the geoprocessing service. You may need to modify the maximum file size and timeouts depending on how large an upload you want your server to accept. Check the local REST SDK documentation installed on your ArcGIS Server machine for information on using an uploaded file with a geoprocessing service. This option is off by default. Allowing uploads to your service could possibly pose a security risk. Only turn this on if you need it.

  • Upload the file using the upload url that is generated in the geoprocessing service . It will give you the itemID of the uploaded file in response.

          http://<servername>:6080/arcgis/rest/services/GP/ConvertKMLToLayer/GPServer/uploads/upload

Response Json:

{"success":true,"item":{"itemID":"ie84b9b8a-5007-4337-8b6f-2477c79cde58","itemName":"SStation.csv","description":null,"date":1409942441508,"committed":true}}

  • Invoke the geoprocessing service with the item id as the GPDataFile input ,

     For Ex: KMLInput value would be  {"itemID":"ie84b9b8a-5007-4337-8b6f-2477c79cde58"}

  • The result will be added to map service with job id if you have configured the view the GP results in a map service. Or you can read the response as it returns.

Hope this helps ....

Thanks,

Mani

0 Kudos
GarySumners
New Contributor

Thanks for the info, Mani...but it leaves me thoroughly confused regarding the following from the "Geoprocessing Widget Tags" reference at ArcGIS Viewer for Flex :

<inputparams>
The input parameters for the geoprocessing task. It has the following child tag:
<param>
The input parameter. It has the following attributes in addition to child tags:
  • name—Name of the input parameters as defined on the server. Required.
  • type—Type of parameter. Valid values are featurerecordset, string, boolean, long, double, date, linearunit, datafile, GPDataFile [added in version 3.2], rasterdatalayer [added in version 3.3], and multivalue:string. Required.

    NoteNote:

    If working with the GPDataFile input type, a UI to upload file(s) displays. The GP service configured with the widget must support uploads. This functionality is provided beginning with ArcGIS 10.1.

Above is the sequence I'm following with my use of the "GPDataFile" parameter type, which strongly implies that within the Geoprocessing Widget itself, there is supposedly a method for automatically accomplishing the back-end tasks you mentioned in your response.  It's listed as available from version 3.2 of the Flex Viewer, and I'm using the 3.3 version.

Is it that this is documented as available yet wasn't actually implemented in the Geoprocessing Widget, or is it that I'm using the advertised function incorrectly?  I'd rather not have to build a completely different widget in order to achieve a result advertised as already existing, which is what I'd be doing by following your method.

Thanks again for your assistance so far....

0 Kudos
ManikandanKalyanasundaram1
New Contributor II

Hi Gary,

I understood the exact issue now.

I think the widget will work with out any modifications as per API documentation.

Can you please make sure the upload capability is enabled for the service ?

I have provided you the sample URL below.

http://<serverNAme>:6080/arcgis/rest/services/<service>/GPServer/uploads

Can you pls verify this and if not delete the service and publish with upload capability again. I typically forget to enable this one. When modifying the service it wont enable this property. We have to delete and publish again.

Thanks,

Mani

0 Kudos
GarySumners
New Contributor

Good Morning!

Yes, that service does have upload capability that does indeed function.  I see from re-reading my initial summary at the beginning that I'd left out specifically stating that the upload function works, simply implied it by the other statements.  The back-end GP service I built does correctly and completely function if used manually or used within ArcMap, it's only the Geoprocessing Widget's "GPDataFile" input case where I'm having issues.

Just as a reassurance, the direct-access to the GP service upload is via the usual trio of Upload Item/Register Item/Info at http://[redacted].net/arcgis/rest/services/Regional/KMLService/GPServer/uploads

Alternatively, as is implied by your sample link, you have this same type of service generated.  Is there a possibility that you can send me the structure you used for your GPservice, on the off chance that yours uses the KML to Layer tool differently?  It would be strange but not impossible for me to have generated a working GP service which is nevertheless incompatible with the widget....

0 Kudos
CristianPinheiro_de_Souza
New Contributor

Hi

I understod the services rest to upload and itemId, how it works with Javascript for example. But, how is it works with ArcObjects?

For upload services, I have used IUploadsClient interface and worked. The interface return the id to use like itemId and I saw the file in upload directory of ArcGIS Server. The service works in browser, runtime and javascript. But how can I use this id in geopocessor with ArcObjects?

I tried this:

IServiceUploadsClient serviceUploadsClient = new UploadsClientClass();

IUploadsClient uploadsClient = (IUploadsClient)serviceUploadsClient;

uploadsClient.TimeoutInSecs = 380;

uploadsClient.Init(agsServerConnection);

IUploadItem uploadItem = serviceUploadsClient.ServiceUploadFile(zipFileName, "Teste upload", agsServerObjectName);

// Ok here, I receveid ID. After this... I do not know how to do.

IGPDataFile gpDataFile = new GPDataFileClass();

gpDataFile.File = "{'itemID':'" + uploadItem.ID + "'}";

// I have already tried gpDataFile.File = uploadItem.ID;

IVariantArray variantArray = new VarArrayClass();

variantArray.Add(gpDataFile);

IGeoProcessorResult geoprocessorResult = _geoprocessor.ExecuteAsync("UploadFile", variantArray);

IGPDataFile looks does not work. The status of job was failed and I always receve messages saying "Parameters are not valid.\nERROR 000840: The value is not a File.".

What is wrong in this?

Thanks

Cristian

0 Kudos