ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Stage Service

  • Summary
  • Usage
  • Syntax
  • Code Sample
  • Environments
  • Licensing Information

Summary

Stages a service definition. A staged service definition (.sd) file contains all the necessary information needed to publish a GIS service, including data that must be copied to the server because it does not appear in the server's data store.

Usage

  • This tool converts a service definition draft (.sddraft) into a service definition that can then be input to the Upload_Service_Definition tool to upload and publish the GIS service to a server. Draft service definitions cannot be used to publish a GIS service directly.

  • Whenever you share a service using ArcGIS for Desktop, the Stage Service tool is run and you will see a result in the geoprocessing Results window.

  • Service definition drafts can be created using ArcGIS for Desktop or by using the arcpy functions CreateMapSDDraft (in arcpy.mapping), CreateImageSDDraft, or CreateGPSDDraft.

  • Once staged, the input service definition draft is deleted.

Syntax

StageService_server (in_service_definition_draft, out_service_definition)
ParameterExplanationData Type
in_service_definition_draft

Input draft service definition. Service definition drafts can be created using ArcGIS for Desktop. See the help topic About draft services for more information. You can also use the arcpy.mapping function CreateMapSDDraft to create draft service definitions.

Once staged, the input draft service definition is deleted.

File
out_service_definition

Resulting service definition. The default is to write the service definition to the same directory as the draft service definition

File

Code Sample

StageService example (Python window)

Stages a service definition.

import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.StageService_server("myMapService.sddraft", "myMapService.sd")
Publishing workflow example (stand-alone script)

The following script demonstrates a publishing workflow using Stage_Service and Upload_Service_Definition.

# Name: StageService_UploadServiceDefinition_example2.py
# Description: Use a service definition draft to create a service definition
# and then upload and publish that service definition.
# Requirements: Connection to an ArcGIS Server or My Hosted Services

# Import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data"

# Set local variables
inServiceDefinitionDraft = "myMapService.sddraft"
outServiceDefinition = "myMapService.sd"

# Execute StageService
arcpy.StageService_server(inServiceDefinitionDraft, outServiceDefinition)

# Set local variables
inSdFile = outServiceDefinition
inServer = "GIS Servers/myServerConnection"

# Execute UploadServiceDefinition
arcpy.UploadServiceDefinition_server(inSdFile, inServer)
Overwriting services example (stand-alone script)

The following script creates and uploads a service defintion that can be used to overwite an existing service.

# Name: StageService_example3_UploadServiceDefinition_example4.py
# Description: Creates a service definition that can be used to overwrite an 
#              existing service. When this service definition is published it 
#              will overwrite the existing service.
# Requirements: Connection to an ArcGIS Server or My Hosted Services


# Import system modules
import arcpy
from arcpy import env
import xml.dom.minidom as DOM 

# Set environment settings
env.workspace = "C:/data"

# Set local variables
inServiceDefinitionDraft = "myMapService.sddraft"
outServiceDefinition = "myMapService.sd"
newType = 'esriServiceDefinitionType_Replacement'

xml = draftPath + in_sd_draft
doc = DOM.parse(xml)
descriptions = doc.getElementsByTagName('Type')
for desc in descriptions:
    if desc.parentNode.tagName == 'SVCManifest':
        if desc.hasChildNodes():
            desc.firstChild.data = newType
outXml = xml    
f = open(outXml, 'w')     
doc.writexml( f )     
f.close()

# Execute StageService
arcpy.StageService_server(inServiceDefinitionDraft, outServiceDefinition)

# Set local variables
inSdFile = outServiceDefinition
inServer = "GIS Servers/myServerConnection"

# Execute UploadServiceDefinition
arcpy.UploadServiceDefinition_server(inSdFile, inServer)

Environments

  • Current Workspace

Licensing Information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related Topics

  • An overview of the Publishing toolset
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal