We want to provide shapefile download support for our web applications. We have implemented shapefile downloads using ArcObjects with ArcMap installed on a desktop, but want to also provide this functionality from our controller action methods inside our MVC web applications. It appears that writing a server object extension would be the correct way to achieve this.
Has anyone already implemented this as a server object extension? Any advice on the "correct" way to handle this would be appreciated.
I have implemented SOE's before but that's not the approach I'd follow here. This is something I've addressed in the past using the geoprocessing framework.
Here's how I solved the problem. I wrote a Python Toolbox the had a FeatureSet (GPFeatureRecordSetLayer) input parameter (a feature set is a json based representation of feature data). My Python toolbox used the JSONToFeatures tool in the Conversion toolbox to write the FeatureSet data into the Scratch Geodatabase. I then used the FeatureClassToShapefile tool in the Conversion toolbox to write the Shapefile files into a temp directory on the server, followed by standard Python libraries to zip up the result and finally assignment of the zip file to an output parameter of datatype File on the tool.
I then deployed the tool to ArcGIS Server. (You run the tool in ArcMap and then share the result appearing in the geoprocessing Result window).
One other thing you'll want to consider is how long it will take for the server to complete the largest anticipated job. If your pushing the timeout limit of your client (a browser) you'll need to modify the implementation outlined above to allow the geoprocessing tool to accept an uploaded file. In the client you'll have to upload the feature data as a file and then use the geoprocessing framework's job polling infrastructure to sense when the job is done and complete the download to the client.
Thanks for your feedback. Sometimes we will iterate through features that are already in the map on the browser and then sometimes we can create the shapefile directly from a query of the feature class on the server, so we're wanting to implement it both ways. We have already written the .Net classes to create the shapefile three different ways (manually iterating through a set of features, feature class query, and database query) and return a FileStreamResult to the browser, which worked great on our developer computers in their Visual Studio IDEs by creating an instance of the desktop runtime. When they published to the server we realized that our implementation was not optimal for publishing on the server.
I will take a look at using the geoprocessing framework...thanks again for your feedback on this.