Récapitulatif
Lists the names of map services for a designated ArcGIS for 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 for Server.
You can list Map Services using the ArcGIS for Server Administrator API which is available through the ArcGIS Site Directory. The default URL of the ArcGIS for Server Site Directory is as follows:
http://<server name>:6080/arcgis/admin
An example of using Python and the ArcGIS for Server Administrator API to list Map Services is below:
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 for Server REST API which is available through the ArcGIS Services Directory. The default URL of the ArcGIS for Server Services Directory is as follows:
http://<server name>:6080/arcgis/rest/services
To get started using the ArcGIS for Server Services Directory and REST API, see the help within the Services Directory.
An example of using Python and the ArcGIS for 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()
Syntaxe
ListMapServices (connection_url_or_name, server, {connection_username}, {connection_password}, {connection_domain})
Paramètre | Explication | Type de données |
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. (La valeur par défaut est 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. (La valeur par défaut est 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. (La valeur par défaut est None) | String |
Valeur renvoyée
Type de données | Explication |
List | A Python list of map services. |