Skip To Content

ListMapServices

Summary

Legacy:

This method has been deprecated starting at ArcGIS 10.1 for Server and ArcGIS 10.1 for Desktop and will return a runtime error. Please consult the ArcGIS documentation for the usage of the new ArcGIS Server Administrator API.

Lists the names of map services for a designated ArcGIS Server.

Discussion

This method has been deprecated starting at ArcGIS 10.1 for Server and ArcGIS 10.1 for Desktop and will return a runtime error.

ArcGIS 10.1 for Server has a new architecture which may require you to adjust how you work with the server. See the following help topic for more information: What to expect when migrating to ArcGIS Server.

You can list Map Services using the ArcGIS Server Administrator API which is available through the ArcGIS Site Directory. The default URL of the ArcGIS Server Site Directory is as follows:

http://<server name>:6080/arcgis/admin

Note:

The URL of the Site Directory may vary if you have configured ArcGIS Server Web Adaptor to work with your site. For example, the inclusion of the port number, 6080, may not be required. Check your web adaptor configuration to obtain the correct URL.

An example of using Python and the ArcGIS Server Administrator API to list Map Services is below:

Note:

A code sample to generate an ArcGIS Server token can be found here: 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)

You can also list Map Services using the ArcGIS Server REST API which is available through the ArcGIS Services Directory. The default URL of the ArcGIS Server Services Directory is as follows:

http://<server name>:6080/arcgis/rest/services

To get started using the ArcGIS Server Services Directory and REST API, see the help within the Services Directory.

An example of using Python and the ArcGIS Server REST API to list Map Services is below:

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()

Syntax

ListMapServices (connection_url_or_name, server, {connection_username}, {connection_password}, {connection_domain})
ParameterExplanationData Type
connection_url_or_name

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

String
server

A string that represents the ArcGIS Server host name.

String
connection_username

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

(The default value is None)

String
connection_password

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

(The default value is None)

String
connection_domain

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

(The default value is None)

String
Return Value
Data TypeExplanation
List

A Python list of map services.


In this topic