过渡服务 (Server)

许可等级:BasicStandardAdvanced

摘要

过渡服务定义。过渡的服务定义 (.sd) 文件包含发布 GIS 服务所需的全部必要信息,包括必须复制到服务器的数据,因为其未在服务器的数据存储中显示。

用法

语法

StageService_server (in_service_definition_draft, out_service_definition)
参数说明数据类型
in_service_definition_draft

输入草稿服务定义。可使用 ArcGIS for Desktop 创建服务定义草稿。有关详细信息,请参阅关于草稿服务帮助主题。还可使用 arcpy.mapping 函数 CreateMapSDDraft 创建草稿服务定义。

过渡操作完成后,输入的草稿服务定义即被删除。

File
out_service_definition

生成的服务定义。默认情况下,服务定义将作为草稿服务定义写入同一目录

File

代码实例

过渡服务 (StageService) 示例(Python 窗口)

过渡服务定义。

import arcpy
from arcpy import env
env.workspace = "C:/data"
arcpy.StageService_server("myMapService.sddraft", "myMapService.sd")
发布工作流示例(独立脚本)

以下脚本演示了使用 Stage_ServiceUpload_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, Spatial Data 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)
覆盖服务示例(独立脚本)

以下脚本可创建并上传能用于覆盖现有服务的服务定义。

# 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, Spatial Data 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)

环境

相关主题

许可信息

ArcGIS for Desktop Basic:是
ArcGIS for Desktop Standard:是
ArcGIS for Desktop Advanced:是
9/15/2013