How to use
See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.
Deploy the SOE
- Log in to ArcGIS Server Manager and click Site.
- Click Extensions.
- Click Add Extension.
- Click Browse and navigate to the .soe file, which by default is located at <ArcGIS DeveloperKit install location>\Samples\ArcObjectsNet\ServerSpatialQueryRESTSOE\CSharp\SpatialQueryREST\bin\Debug\SpatialQueryREST.soe.
- Click OK.
Enable the SOE on a service
- Start ArcMap and click File > Open.
- Browse to or type the location of Yellowstone.mxd, which is located in <ArcGIS Developer Kit Location>\Samples\data\Yellowstone.
- Click File > Share As > Service.
- Click Save a service definition and click Next.
- Choose "No available connection" and check "Include data in service definition when publishing".
- Change the Server type to ArcGIS Server.
- Leave the Service name as Yellowstone and click Next.
- Choose a location where you want to save the service definition, then click Continue.
- Click Stage to create the service definition. In the success message, note the path of your service definition (.sd).
- Copy the Yellowstone.sd file to the machine running ArcGIS Server Manager.
- On the machine running ArcGIS Server Manager, log in to Manager and click Services.
- If necessary, click the Manage Services tab.
- Click Publish Service.
- Click Browse, browse to the location of Yellowstone.sd on the local machine, and click Open. Then click Next.
- Accept the default properties for the service by clicking Next.
- Click Publish. This creates the USA map service.
- On the Services tab of Manager, select the USA map service, then select Capabilities. In the list of available capabilities, find SpatialQueryREST and check the box to enable it. If there is a list of available operations allowed, select all of them.
- Click Capabilities and click SpatialQueryREST (be careful not to uncheck the box). You are now viewing the properties page for the service. Ensure that the LayerName is "veg" (no quotes) and that the FieldName is "PRIMARY_" (no quotes).
- Click Save, then Restart to restart the service.
Test the SOE in the ArcGIS Server Services Directory
- Clear the Representational State Transfer (REST) cache of your Services directory. You can find cache clearing options if you open a web browser and log into http://<server name>:6080/arcgis/rest/admin. Click REST Cache, then click Clear Cache Now.
- Access your services directory by opening http://<server name>:6080/arcgis/rest/services in a Web browser.
- Click Yellowstone, scroll down to the bottom of the page, and click SpatialQueryREST. You’re now at the root resource page of your SOE.
- Click the one operation available, SpatialQuery. You can test this operation by adding some simple JavaScript Object Notation (JSON) parameters in the input boxes.
- Type {x:544000,y:4900000} in the location box.
- Type 5000 in the distance box.
- Click either the SpatialQuery (GET) or SpatialQuery (POST) button. You should see a long JSON response containing the clipped polygon geometries from the spatial query. Scroll to the bottom of the response and you’ll see a list of the total areas for each vegetation type.
Use the SOE in a JavaScript application
- Using a text editor, such as Notepad, open the SpatialQueryRESTClient.html file included with this sample. This is a sample application built with the ArcGIS application programming interface (API) for JavaScript that uses the SOE. You must have Internet access to successfully run this application.
- Find the line of code, var soeURL = "http://<server name>:6080/arcgis/rest/services/Yellowstone/MapServer/exts/SpatialQueryREST/SpatialQuery";
- If necessary, replace the uniform resource locator (URL) in the preceding line of code with the REST URL to your SOE.
- Find the line of code, var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://<server name>:6080/arcgis/rest/services/Yellowstone/MapServer");
- If necessary, replace the URL in the preceding line of code with the REST URL to your Yellowstone map service.
- Save the file.
- Double-click the SpatialQueryRESTClient.html file in Windows Explorer to run it.
- Type a buffer distance, such as 5000, then click anywhere on the map. After a few seconds, you'll see the buffered and clipped features displayed on the map, along with a table summarizing the area of each vegetation type.
SpatialQueryREST\SpatialQueryREST.cs | The SOE code |
SpatialQueryREST\bin\Debug\SpatialQueryREST.soe | The deployable SOE file |
SpatialQueryRESTClient.html | JavaScript client application for the SOE |
Download the files for all languages
See Also:
Walkthrough: What's in the REST SOEHow to develop the REST SOE
How to register the REST SOE
How to develop a property page for the REST SOE
How to enable and test the REST SOE on a service
How to use the REST SOE in a Web application