To publish a geoprocessing service, you need a result in the Results window and an administrator connection to an ArcGIS Server.
Note:
Beginning at 10.4, only administrators can publish a geoprocessing service. To allow publishers to publish geoprocessing services, see Change geoprocessing service and service extension publishing privileges.
To publish a service, right-click the result and choose Share As > Geoprocessing Service, as illustrated below. This will open a series of dialog boxes (the Share as Service step-by-step wizard and the Service Editor) where you create the service definition and the initial task within the service. This initial task is the same as the tool that created the result. You can add additional results to the service, and each result becomes a task within the service.
The Share As menu choice will be disabled for a result when:
- Invalid result—a result that has an execution error .
- The Service Editor is already open—you can only publish one service at a time. If you want to add a result to a service you are sharing, see Adding a task to a geoprocessing service.
- The result was created by executing a geoprocessing task—only tools that execute on your computer can be shared.
- The result is from an execution of the Stage Service or Upload Service Definition tool—these tools cannot be made into services.
- The result uses a model tool that has list variables within a model—model tools that use list variables cannot be made into a geoprocessing task.
Publishing batch geoprocessing services is also not possible.
If your geoprocessing tool contains output workspace parameters, they will be disabled once the tool has been published as a geoprocessing service.
Preparing to publish
Before using the Share as Service wizard or the Service Editor, there are a few preparations you should make.
Document your tool
When publishing, your tool is checked to make sure it has minimal documentation—a summary and one or more tags—and you can enter these using the Service Editor. But you'll want to provide other elements such as parameter help and usage tips, and the best way to provide these is to update the item description of your tools before publishing.
Project data and the data store
A server's data store is used to determine the location of a task's project data, as described in the topic A quick tour of authoring and sharing geoprocessing services. Before publishing, verify that the data store contains entries for your project data that resides on the server.
Layers in the table of contents
Part of designing and authoring a service is determining what layers will be available to clients of the task. For example, the Generate Near Table task shown in A quick tour of authoring and sharing geoprocessing services uses layers in the ArcMap table of contents to create a choice list of layers available to the client. If there are additional layers you want to be part of a choice list, add them to the table of contents before publishing.
One of the options for a geoprocessing service is to view the result with a map service. If you choose to view results as a map service, a map to the task result is created on the server using ArcMap, then transported back to the client. The symbology, labeling, transparency, and all other properties of the returned map are the same as the output layer in your current ArcMap session. You may want to update the symbology of the output layer before sharing the result.
Feature and table schemas
If you plan on allowing clients of your task to provide their own features or table rows as input to your task, you may want to review the schema of the layers, datasets, or tables used to create the result you're publishing.
Learn more about feature and table schemas for task parameters
Small output datasets
When a geoprocessing service is published, all output datasets in your result are copied to the server to ensure that a result map service can initialize and run. These output datasets are needed because a map service checks the data sources for all its layers during startup. If any dataset does not exist, the map service fails to start.
Even if you do not specify a result map service at the time of publishing, you can change this later without having to republish the service, so the output datasets are copied regardless of whether you specified a result map service at the time of publication.
When your task executes, this (copied) output data will be overwritten and the map server will draw the results of your task (not the copied data).
If your output dataset is large, the publishing process will take longer to copy the data to the server. You may want to run your tool so that smaller output data is created.
Connecting to a server with administrator or publisher privilege
You don't need to be connected to a server in order to define a service; you can create a service definition file which you can upload to a server at a later time. But, eventually, you'll need an administrator or publisher connection to an ArcGIS Server in order to create a functioning service. You can create this connection when publishing, or create the connection before publishing by clicking Add ArcGIS Server in the Catalog window of ArcMap.
Share as Service wizard
After clicking Share As > Geoprocessing Service, the Share as Service wizard opens, as illustrated below.
In the first panel, you can choose one of three options:
- Publish a service—you connect to a server and publish or save as a service definition file to publish later.
- Save as service definition file—in this case, you don't need to connect to a server. You'll create a service definition file which you can publish later.
- Overwrite an existing service—this is the same as stopping and deleting an existing service prior to publishing.
If you choose Publish a service, the next dialog box is where you provide the server connection and the name of your service. After clicking Next, you can create a folder to contain the service. By default, services are published to the root folder (root) of ArcGIS Server. Services can be organized into subfolders under the root folder. Choose the folder where you want to publish the service, or create a new folder to contain the service.
If you choose Save as service definition file, the next panel gives you two options: either create a service definition for a specific server or create a generic server definition file. The last panel is where you specify the location to save the completed service definition.
Tip:
You can familiarize yourself with the Share as Service wizard and the Service Editor without having to make a connection to a server or publish a service. When the Share as Service wizard opens, choose Save as service definition file. In the next panel, choose No available connection. The next panel will ask where to save the service definition file and you can accept the default. The Service Editor will open and you can review all the settings, make changes, preview the task dialog box as it would appear in ArcGIS, and analyze the service for warnings and errors. You can exit the Service Editor at any time and when asked if you want to save a draft service, click No.
Learn more about service definition files
If you choose Overwrite an existing service, the next panel is where you choose the service to overwrite.
The Service Editor
Once you've defined the service you want to create or overwrite, the Geoprocessing Service Editor opens, as illustrated below. On the left side is a categorized list of settings that you can modify. Some of these settings apply to the service while others apply to tasks within the service. On the top right are buttons that perform actions.
Service settings
Service settings define how clients will access the service and the tasks within. These settings apply to all tasks within the service. For example, one of the Parameters settings determines whether the output of tasks will be returned to the client as a map image.
Task settings
Clicking a parameter in the left panel will show its settings in the right panel of the Service Editor. These settings are based on the parameter type such as feature, table, raster, string, file, Boolean, and so on.
Import settings
You can import the properties of an existing service definition file or published service. Using this method, you can avoid configuring service properties using the Service Editor ; instead, you can import the properties of a similar service definition file or published service.
Adding a task
A geoprocessing service can contain more than one geoprocessing task. Click the Add Result button to add a new task.
Removing a task
To remove a geoprocessing task, right-click the task and select Remove. When you remove a task, the task is removed from the service—the corresponding geoprocessing result or its tools will not be deleted.
Previewing a task
Click the Preview button to show how the task dialog box will appear when used in ArcGIS Desktop. Previewing a task helps you verify modifications you may have made to task parameters. If you have multiple tasks, select the task (or one of its parameters) before clicking the Preview button. You can preview your tasks as many times as you wish during publishing.
Analyzing a service
Clicking the Analyze button scans your service and tasks for issues and opens the Prepare window, showing you errors and warnings . Errors must be resolved before you can publish the service. For any row, you can right-click the row and click Help for a detailed description of the problem and how to resolve it. You can skip analyzing the task and publish the task, which will automatically analyze your task before publishing it.
Publishing the service
Click the Publish button to publish the service. The service is analyzed and if there are errors, the Prepare window will open and the service will not be published. If there are no errors, a progress dialog box will open and you'll be notified when the service finishes publishing.
Saving a draft service
If you exit the Service Editor before publishing, you'll be asked if you want to save a draft service definition. If you choose to do so, a draft service definition file (.sddraft) is created and will contain all the modifications you made to the service. You can open this draft service definition from ArcCatalog or the Catalog window. Where the draft service definition is saved depends on whether you chose Publish a service or Save as service definition file in the first panel of the Share as Service wizard.
- If you chose Publish a service, the draft service will be saved to the Drafts folder on the server you chose to publish to.
- If you chose Save as service definition file, the draft service will be saved in the location you chose to save the service definition.