Server Object Extensions (SOEs) can be incredibly powerful, but they can also be a pain to debug.
- Rebuild solution
- Open ArcGIS Manager in browser -> Site -> Extensions -> Update Extension by selecting .soe file.
- Restart all of the services that depended on the SOE.
- Attach Visual Studio to process.
Steps 2 & 3 are the really annoying ones, but they can be automated!
It turns out this is really a post about REST and Python.
When you update an SOE through the ArcGIS Manager app (http://localhost/arcgis/manager), the web application is actually making calls to ArcGIS Server REST admin endpoints.
Automate with Python
I’ll cut to the chase.
See the full script here:
Usage (simply run from command line after rebuilding SOE solution):
C:\Projects\_General\_Code\soe-updater>python update_soe.py Retrieving token... Retrieved: oUK04q-J8ORWDUrSWGPfq8zAU29u3q5_YZ79ZvcFZx8kFneOMb5Z2Y2Yf19 Uploading SOE... Uploaded: ibd792bae-a986-4861-8ac3-c16d42f4d610 Updating SOE... Updated! Starting services... Starting service_folder/service.MapServer Started!
Your SOE will be updated and services restarted. You can re-attach to the service processes or if you’re using
System.Diagnostics.Debugger.Launch(); in your
Init() function, you’ll automatically be greeted with the dialog to attach your process once the script finishes and the services restart.
Now a little explanation of what’s going on…
REST API Calls
Because we’re going to automate this, we need a preliminary step. We’ll generate a token that can be passed to subsequent steps.
Upload the SOE
The .soe file that gets generated after building in Visual Studio is uploaded to ArcGIS Server and returns an itemID.
Update the SOE
Another call references the uploaded .soe through the itemID and updates the extension.
After the SOE is updated, all services that use it are stopped and must be restarted. This can also be accomplished through REST calls:
These calls are all pretty straightford to automate in a Python script using the requests library (http://docs.python-requests.org/en/latest/).