ListMapServices (arcpy.mapping)

摘要

法律声明法律声明:

此方法已在 ArcGIS 10.1 中弃用并会返回运行时错误。有关新的 ArcGIS for Server Administrator API 的使用方法,请查阅 ArcGIS 文档。

列出指定 ArcGIS for Server 的地图服务名称。

讨论

此方法已在 ArcGIS 10.1 中弃用并会返回运行时错误。

ArcGIS for Server 10.1 具有全新架构,这种架构可能要求您调整服务器的使用方式。有关详细信息,请参阅以下帮助主题:新特性之 ArcGIS 10.1 for Server迁移至 ArcGIS 10.1 for Server迁移至 ArcGIS 10.1 for Server 时可能出现的情况。

您可以使用 ArcGIS 站点目录中的 ArcGIS for Server Administrator API 列出地图服务。ArcGIS for Server 站点目录的默认 URL 如下所示:

http://<服务器名称>:6080/arcgis/admin

注注:

如果已将 ArcGIS for Server Web 适配器配置为与站点配合使用,则站点目录的 URL 可能有所不同。例如,可能不需要端口号 6080。检查 Web 适配器配置以获得正确的 URL。

下面演示了使用 Python 和 ArcGIS for Server Administrator API 列出地图服务:

注注:

有关生成 ArcGIS for Server 令牌的代码示例,请参阅:DeleteMapService

import json, urllib2

server = "<server>"
port = "6080"
token = '<token string>'
baseUrl = "http://{}:{}/arcgis/admin/services".format(server, port)

def getCatalog(token):
  catalog = json.load(urllib2.urlopen(baseUrl + "/" + "?f=json&token=" + token))
  print 'Root' 
  if "error" in catalog: return
  services = catalog['services']
  for service in services:
    response = json.load(urllib2.urlopen(baseUrl + '/' + service['serviceName'] + '/' + service['type'] + "?f=json&token=" + token))
    print '  %s %s (%s)' % (service['serviceName'], service['type'], 'ERROR' if "error" in response else 'SUCCESS')
  folders = catalog['folders']
  for folderName in folders:
    catalog = json.load(urllib2.urlopen(baseUrl + "/" + folderName + "?f=json&token=" + token))
    print folderName
    if "error" in catalog: return
    services = catalog['services']
    for service in services:
      response = json.load(urllib2.urlopen(baseUrl + '/' + service['serviceName'] + '/' + service['type'] + "?f=json&token=" + token))
      print '  %s %s (%s)' % (service['serviceName'], service['type'], 'ERROR' if "error" in response else 'SUCCESS')

getCatalog(token)

您也可以使用 ArcGIS 服务目录中的 ArcGIS for Server REST API 列出地图服务。ArcGIS for Server 服务目录的默认 URL 如下所示:

http://<服务器名称>:6080/arcgis/rest/services

要初步了解如何使用 ArcGIS for Server 服务目录和 REST API,请参阅服务目录中的帮助。

下面演示了使用 Python 和 ArcGIS for Server REST API 列出地图服务:

import json, urllib2

server = "<server>"
port = "6080"
baseUrl = "http://{}:{}/arcgis/rest/services".format(server, port)

def getCatalog():
  catalog = json.load(urllib2.urlopen(baseUrl + "/" + "?f=json"))
  print 'ROOT' 
  if "error" in catalog: return
  services = catalog['services']
  for service in services:
    response = json.load(urllib2.urlopen(baseUrl + '/' + service['name'] + '/' + service['type'] + "?f=json"))
    print '  %s %s (%s)' % (service['name'], service['type'], 'ERROR' if "error" in response else 'SUCCESS')
  folders = catalog['folders']
  for folderName in folders:
    catalog = json.load(urllib2.urlopen(baseUrl + "/" + folderName + "?f=json"))
    print folderName
    if "error" in catalog: return
    services = catalog['services']
    for service in services:
      response = json.load(urllib2.urlopen(baseUrl + '/' + service['name'] + '/' + service['type'] + "?f=json"))
      print '  %s %s (%s)' % (service['name'], service['type'], 'ERROR' if "error" in response else 'SUCCESS')

getCatalog()

语法

ListMapServices (connection_url_or_name, server, {connection_username}, {connection_password}, {connection_domain})
参数说明数据类型
connection_url_or_name

A string that represents the URL of the ArcGIS for Server to which you want to get a list of services.

String
server

A string that represents the ArcGIS for Server host name.

String
connection_username

A string that represents a user name used to connect to the ArcGIS for Server. In order to get a list of map services this user name should be a member of the ArcGIS for Server admin group. This variable is only necessary when connecting to a UNIX/Linux ArcGIS for Server.

(默认值为 None)

String
connection_password

A string that represents a password used to connect to the ArcGIS for Server. This variable is only necessary when connecting to a UNIX/Linux ArcGIS for Server.

(默认值为 None)

String
connection_domain

A string that represents a domain name used to connect to the ArcGIS for Server. This variable is only necessary when connecting to a UNIX/Linux ArcGIS for Server.

(默认值为 None)

String
返回值
数据类型说明
List

地图服务的 Python 列表。

9/15/2013