Route application using the NAServer extension in ArcGIS Server via a Web service


Purpose
This sample is a stand-alone application that shows how to programmatically perform point-to-point routing using the Network Analyst server extension connecting to a Web service catalog. This sample demonstrates some of the key programming patterns when using Network Analyst server objects, such as the following:
  • Connecting to the Web service.
  • Accessing solver properties from a route analysis layer.
  • Creating stop locations from a set of x,y coordinates.
  • Setting NAServer route solver parameters.
  • Solving to find the best route.
  • Accessing NAServer result objects (map showing the route, driving directions, input and output NAClasses).

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample.

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/SanFranciscoNetwork.
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.

  1. Click the different tabs to get the solver results according to your NAServerRouteParams.
  2. Publish a network analysis service (see the following section).
  3. Open the solution file in Visual Studio.
  4. In the Solution Explorer, right-click References and choose Add Web Reference.
  5. Type the uniform resource location (URL), http://localhost/arcgis/services/SanFrancisco/MapServer/NAServer?wsdl (change localhost if the ArcGIS server is on a different machine), then click Go.
  6. In the Web Reference Name control, type the name WebService.
  7. Click Add Reference.
  8. Save the solution.
  9. Build and run the project.
  10. Choose the route solver options.
  11. Click the Find Route button.
  12. Click the different tabs to get the solver results according to your NAServerRouteParams.

Publish a network analysis service
  1. Start ArcCatalog.
  2. Browse to <Your ArcGIS Developer Kit install folder>\samples\data\SanFrancisco.
  3. Right-click SanFrancisco.mxd and click Publish to ArcGIS Server.
  4. Type SanFrancisco as the service name and click Next.
  5. Ensure Network Analysis is selected and click Next.
  6. Click Finish.
  7. Exit ArcCatalog.

Route_WebServiceClass.cs Code for the main form.
Download the C# files
Route_WebServiceClass.vb Code for the main form.
Download the VB.NET files

Download the files for all languages




Additional Requirements
  • Data requirements—The Network Analyst sample data for the San Francisco region can be used to create the required server objects. To use your data with this sample, refer to the documentation on designing and building network datasets.
  • The network dataset must be built with at least one cost attribute, likely based on distance. Optionally, you can add more cost attributes based on time units, for example, add restrictions or direction information to generate driving directions.
  • The map document must contain the network dataset, a route analysis layer, and a point feature layer.

Development licensing Deployment licensing
Engine Developer Kit Engine Runtime: Network
ArcView: Network Analyst ArcView: Network Analyst
ArcEditor: Network Analyst ArcEditor: Network Analyst
ArcInfo: Network Analyst ArcInfo: Network Analyst