I like the motto, "if you can't do in on desktop, you won't be able to do it on server." Keeping this idea in mind, I first wrote the tool as a add-in for ArcMap. This allowed me to debug core business logic for the tool without the complications of the server.
The main difference between a 'desktop tool' and Server Object Extension is the ability to deserialize requests and serialize responses over http. Since I was new to C# and Server Object Extensions, I first published a sample SOE called SimpleRESTSOE from the samples folder of the ArcGIS 10 install directory. This tool was simply an echo service (i.e. pass a string in, and get the string back). Requests declare 'text' and 'f' (output format) parameters as part of a url request:
and they SOE responds:
I got the sample SOE registered with Windows using the command:
RegAsm SimpleRESTSOE.dll /codebase
I then registered the SOE with ArcCatalog and the Server Manager using the companion file located in the samples folder (RegisterSimpleRESTSOE.dll).
Once I verified the sample SOE was running, I simply started modifing the rest schema to take my custom parameters. To do this, I modified the CreateRestSchema method of the COM class for the tool. I also added some additional variables to support my business logic:
After modifying the CreateRestSchema method the tool was wired to take the following request:
I wrapped my business logic in a function and called it from the REST operation's handler EchoInput. THe EchoInput method parses the incoming request, calculates the watershed, and serialize the output.
Global Hydrosheds Lookup
I built a small client application to test Find Watershed over the web. In the app, the user first supplies the location by clicking on the map. The click location is passes to the server into a query against the lookup map to determine the hydroshed id then :
building a client