Sunday, 1 November 2015

Is it possible to create a new service definition file from an existing ArcGIS service?


Is it possible to create a new service definition file from an existing ArcGIS service?


I have a python script that updates data on a daily basis. I have figured out how to restart/overwrite my existing service so that it will represent the change in the data. However doing so uses the default settings for the new service.


If possible, I would like to create a new service definition file from an existing service so that I do not have to go back manually and change the following parameters and capabilities:


Max # of Records Returned by Server, Lock Database, Max # of instances per machine,


Any advice would be great. Thanks


Here is the solution:


    # Deserialize response into Python object
dataObj = json.loads(data)

httpConn.close()

# Edit desired properties of the service
dataObj["minInstancesPerNode"] = 1
dataObj["maxInstancesPerNode"] = 10

newdict = dataObj["properties"]
newdict["maxRecordCount"] = 5000

# Serialize back into JSON

updatedSvcJson = json.dumps(dataObj)

Answer



You have several options:




  1. Go to the \%server%\arcgisserver\directories\arcgissystem\arcgisinput\%ServiceName%.MapServer\extracted\v101 and open the .mxd document which will allow you to save a new .sd file for re-use.




  2. Use Python or any scripting language of your choice to modify properties of an existing service. This is done by using ArcGIS REST Administrator API. Here is the sample for modifying properties of an existing service. I use it almost daily and it is very easy to write a script altering properties as needed. This is much more efficient imo than creating a service again from .sd.





  3. Publish a service with the required properties directly set by using ArcGIS REST Administrator API and ArcPy. In this case, you will be able to specify the advanced settings in advance. Again, refer to the samples from 2. above to get started.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...