Publishing BufferService (based on SDE Feature Class) to ArcGIS Server

10-13-2013 03:29 PM
Occasional Contributor
I'm trying to create a geoprocessing service, which I want to publish to my ArcGIS Server 10.2 to use it later on in a webmap (based on Java Script).
But until now I fail with the creation of a model builder tool.
I've gone through the tutorial: but it's not clear how to use it with SDE feature classes stored in a enterprise geodatabase.

What I've done so far (using ArcMap Info 10.2):
I've created the following tool:
The output feature class of Buffers is set to: %SCRATCHWORKSPACE%\ClippedBuffers.shp and Buffers is set to "Add to display".

First problem after starting the tool:
Executing: Model22 "Feature Set" "1 Kilometers" C:\Users\Schlomm\Documents\ArcGIS\Default.gdb\ClippedBuffers.shp
Start Time: Mon Oct 14 01:13:57 2013
Executing (Buffer): Buffer "Feature Set" C:\Users\Schlomm\Documents\ArcGIS\Default.gdb\ClippedBuffers.shp "1 Kilometers" FULL ROUND NONE #
Start Time: Mon Oct 14 01:13:57 2013
ERROR 000210: Cannot create output C:\Users\Schlomm\Documents\ArcGIS\Default.gdb\ClippedBuffers.shp
Failed to execute (Buffer).
Failed at Mon Oct 14 01:13:57 2013 (Elapsed Time: 0,12 seconds)
Failed to execute (Model22).
Failed at Mon Oct 14 01:13:57 2013 (Elapsed Time: 0,21 seconds)

It might deal with the %SCRATCHWORKSPACE% variable, which I have to set. So I've tried to set the variable in Geoprocessing > Environments -> Environment Settings -> Workspace to the following (as suggested in the tutorial):
I've cleared the Current workspace and set the Scratch Workspace to the Database Connection, where the feature class is stored, which I'm using for the input.
Is this right to set this this way?

Now I start the tool again and this time it seems to be working. The tool performs successfully and the output shapefile is now located the enterprise geodatabase, where the input point feature class is also stored.
But unfortunately the feature class is empty.

Any ideas?
Or is there any other tutorial for geoprocessing services using server stored feature classes?

Thanks a lot!
0 Kudos
7 Replies
Esri Regular Contributor
If you're using 10.1 or 10.2, use scratchFolder or scratchGDB. Don't use scratchWorkspace unless you've used it in the past. These 2 variables are simply easier to use and will always work.

The error you posted is because you're trying to write a shapefile (.shp) into a file geodatabase. You can't do that.
Your ArcMap's scratchWorkspace environment variable is pointing to your default GDB, thats why that happened. If you want a shapefile, just use the %scratchFolder% variable.

Have a quick read of this :

EDIT: I just re-read this part:
I've gone through the tutorial: but it's not clear how to use it with SDE feature classes stored in a enterprise geodatabase.......I've cleared the Current workspace and set the Scratch Workspace to the Database Connection, where the feature class is stored, which I'm using for the input.

I assume you mean exactly what you said, use an SDE featureclass as input. Not write the output of your buffer operation back to SDE (as your second point implies). If this is what you want to do, whats the reason for writing to SDE? 99% of the time there isn't a real need to write back to SDE, just use the scratch environments as you are but modify that environment setting to a folder in your working directory of your project.
0 Kudos
by Anonymous User
Not applicable
Original User: Schlomm

@your edit: Yes...I want to use a sde based feature class for input. This feature class is connected to a feature service, so people have the option to add new features. Then the feature class contains new features, which have to be buffered. Thatswhy I use the sde feature class as input.

I've thought, I have to write the output back to the SDE connection, because I want to use this service for a JavaScript based map.
If I don't need to write it back to SDE, what would be output directory for the buffer output? Just any local folder or gdb?


0 Kudos
Occasional Contributor
I've proceeded for now by set the output directory to a local folder.  If this is wrong in regard to use this for a web-based map application, please give me a note!
... Once I've start the tool, it gives me the buffered points.  In order to publish the tool, I have to add the tool to the Table of Content in ArcMap, but unfortunately this doesn't work. I get the error message that the data cannot be load.

Any help is much appreciated!
0 Kudos
by Anonymous User
Not applicable
Original User: khibma

Write your output to %scratchFolder%\output.shp or %scratchGDB%\output (shapefile or fgdb-featureclass).
The GP Service returns the "featureclass" (technically speaking it returns a GPFeatureRecordSet which is the features in a GP Service).
The web app will then draw those features.

Your web app doesn't care where the service saves the output to. The web app just gets the features from the service and draws them as its told. The GP/Server framework send the features (in JSON) to the web app.
If you're in 10.1+ you dont make tool layers (as the tutorial you've linked to explains, this was a 10.0 and previous concept). You said you're on 10.2? Updated tutorials for 10.2 are here:
However, there isn't just a buffer one. I'd suggest going through the quick tour here first:
0 Kudos
Occasional Contributor
Dear Kevin,
Thanks for your answer, which was quiete helpful.
I've finally managed to share the geoprocessing model as a geoprocessing service.

Just to be sure....It would awesome, if you could check my model, which is really a basic one (see attachments).
What the model should to: Create a buffer of 1km around the input data, which is a point sde feature class. The buffer should be called via a popup like here:   (Until now I haven't got any idea how to do if you have any tip, feel free to share this ;))

I've run the model from the toolbox (I've need a couple of minutes to realize, that the result is not added if I start the model out of the modelbuilder :D).

From the results window, I've selected Share As-> Geoprocessing Service and I've keeped the default settings.
Capabilities: WPS: not enabled
Parameters: Kept the asynchronous setting with "View results with a map service"
I think the other settings are not really important.

Everything right so far?
Thanks so much!
0 Kudos
by Anonymous User
Not applicable
Original User: khibma

From your screen shot everything is good. A couple minor things:
1) You dont need to set "Add to Display" on the output. In your case it doesn't matter. For what Add to Display does -it's a Modelbuilder only setting. It has no impact in a GP Service. (I explain this so you dont get confused with that setting in the future)
2) Your input SDE layer you said is a feature set. A feature set for input allows the user to enter (or digitize features). However in your case you don't have it exposed as a parameter. Depending on your workflow you want 1 of 2 things:
  a) to change it to a feature class and leave the input as SDE  -- this will always use the sde features
  b) keep it as a feature set, but make it a parameter. Then when someone uses it as a service, they enter their own points

The link you posted is fine, but keep in mind it makes use of a Sync service, thus you call execute in the web app. To use an Async service in a webapp you need to call Submit Job. This example shows both submitJob and how to consume the output when its a result map service.

This is really the main point you need to understand in the javascript side:

   function findHotspot(){
        var gp = new Geoprocessor(gpServiceUrl);
        var params = {
          Query: buildDefinitionQuery()
        //cleanup any results from previous runs 
        //submitJob is called including the parameters for the service. Right now it appears you dont have any
       // any parameters, so your "params" variable would be empty.
        gp.submitJob(params, gpJobComplete, gpJobStatus, gpJobFailed);
0 Kudos
Occasional Contributor
Dear Kevin,
Again: Thanks for your answer :)
Right! My input is a SDE point feature set. This feature set is also used by a feature service, so users are able to create new points in the map. The feature service is already set up and works (users can enter new points in the map application).

So...the goal is, that the geoprocessing service should buffer also the new created points.
To enable this, I have to follow 2b), haven't I? Just switching my input data (the feature set) to parameter mode!?

I will look at the example and I will try to modify it in this way, I'll need it...of course only, if the above mentioned assumptions are right ;)

0 Kudos