ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

ListMapServices

  • 摘要
  • 讨论
  • 语法

摘要

旧版本:

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

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

讨论

此方法自 ArcGIS 10.1 for Server 和 ArcGIS 10.1 for Desktop 起已弃用并会返回运行时错误。

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

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

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

注:

如果您已将 ArcGIS Server Web Adaptor 配置为与您的站点配合使用,则 Site Directory 的 URL 可能会有所不同。例如,可能不需要包括端口号 6080。检查 Web Adaptor 配置以获得正确的 URL。

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

注:

有关生成 ArcGIS 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 Server REST API 列出地图服务。ArcGIS Server 服务目录的默认 URL 如下所示:

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

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

下面演示了使用 Python 和 ArcGIS 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

表示您想要从中获取服务列表的 ArcGIS Server URL 的字符串。

String
server

表示 ArcGIS Server 主机名称的字符串。

String
connection_username

表示用于连接到 ArcGIS Server 的用户名的字符串。为获取地图服务列表,该用户名应为 ArcGIS Server 管理员组的成员。只有在连接到 UNIX/Linux ArcGIS Server 时才需要此变量。

(默认值为 None)

String
connection_password

表示用于连接到 ArcGIS Server 的密码的字符串。只有在连接到 UNIX/Linux ArcGIS Server 时才需要此变量。

(默认值为 None)

String
connection_domain

表示用于连接到 ArcGIS Server 的域名的字符串。只有在连接到 UNIX/Linux ArcGIS Server 时才需要此变量。

(默认值为 None)

String

返回值

数据类型说明
List

地图服务的 Python 列表。

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2019 Esri. | 隐私政策 | 法律声明