Tutorial: Publishing a network analysis service

Release 9.3 E-mail This Topic Printable Version Give Us Feedback

ArcGIS Server supports performing network analysis on transportation networks. This includes finding the best route, finding the closest facilities to an incident, or generating service areas for one or more facilities. To learn more about the different types of network analysis and their capabilities, see Types of network analyses in the ArcGIS Desktop Help.

There are several ways to perform network analysis using ArcGIS Server:

For more detailed information about accessing network analysis functionality in ArcGIS Server, including additional capabilities not supported through the network analysis service, see Network Analyst Library Overview - Server Objects on the ESRI Developer Network (EDN) Web site.

This tutorial walks you through the process of creating a map document capable of being used for network analysis and publishing it as a map service with the network analysis capability enabled. It then lists several developer samples that can consume the network analysis service.

Creating the map document

A network analysis service requires a map service that contains one or more network analysis layers. This means the map document published to ArcGIS Server must contain one or more layers that are network analysis layers created with the Network Analyst toolbar. Currently the network analysis service supports the route, closest facility, and service area analysis layers.

Follow these steps to create a single map document capable of performing all three of these types of network analysis:

  1. Start ArcMap and open a new empty map document.
  2. Ensure the Network Analyst extension is enabled by clicking Tools > Extensions, then checking the Network Analyst extension.
  3. Make the Network Analyst toolbar visible by clicking View > Toolbars > Network Analyst.
  4. A network dataset is required to be in the map to create a network analysis layer. To add one, click File > Add Data, browse to a network dataset, then add it to the map. For this example, choose Streets_ND.nd located in %ARCGISHOME%\DeveloperKit\SamplesNET\Server\data\SanFranciscoNetwork. When prompted if you want to add all feature classes that participate in Streets_ND to the map, do so. You can also add any additional data to your map that you would like to see.
  5. In the table of contents, uncheck the Streets_ND_Junctions layer since most users do not care to see them. Uncheck the network layer referencing the network dataset. This is because it is faster and you have more flexibility drawing the streets using the streets feature layer. Symbolize the streets using a unique value renderer based on the field DISP_CODE.

  6. Add network analysis layers to your map using the buttons on the Network Analyst menu on the Network Analyst toolbar. Click New Service Area, New Closest Facility, or New Route to add a service area, closest facility, or route analysis layer to the map.

  7. Change the symbology of the network analysis sublayers if you want different symbology. For example, you may want to make the Routes feature layer to be 50 percent transparent and have lines that are 10 pixels wide.

  8. Click File > Save to save the map document to disk.

    The name and location of the map document can be anything. However, if you would like all the developer samples to work with this service without any modification, you should save it to the location of the sample map document that comes with the software developmer kit. To do this, follow these steps:

    • Change the name of <ArcGIS install location>\DeveloperKit\SamplesNET\Server\data\SanFranciscoNetwork\SanFrancisco.mxd to orig-SanFrancisco.mxd.
    • Save your map document as <ArcGIS Install location>\DeveloperKit\SamplesNET\Server\data\SanFranciscoNetwork\SanFrancisco.mxd.

Publishing the service

Once you have a map document with a network analysis layer, you're ready to publish it as a network service. You'll publish the map document as a service and enable the network analysis capability, which will create a network analysis service of the same name.

Important: Before publishing your services, be sure to read and follow the guidelines presented in Preparing resources for publishing as services. These will help you ensure that the server has permissions to read and access all the data for your model and your map. Specifically, the ArcGIS Server Object Container (SOC) account needs to have read permissions to the map document, the network dataset, and any additional data in the map document. If you have the components of ArcGIS Server distributed among multiple machines, all the above data must be referenced using UNC paths so that all machines can read it. Finally, the SOC account needs read and write access to the server output directory. If you're using the default server output directory installed with ArcGIS Server (C:\arcgisserver\arcgisoutput), then the installation process already applied the appropriate permissions for you.

Follow these steps to publish the services via ArcGIS Server Manager:

  1. Log in to ArcGIS Server Manager and click Publish a map, globe, or other GIS resource as a service.

    Tip: There are two wizards in Manager that you can use to publish services. This link takes you to the Publish GIS Resource wizard, which is the simplest way to create a service. It asks you the minimum amount of information needed to create a service.

    The other way to create services is the Add New Service wizard. This wizard is the completely manual way of publishing a service; it prompts you for all the service parameters.

  2. On the first page of the wizard, you're prompted for the resource that you want to publish. This is the map document with the network analysis layers. If it's in a shared directory, you can browse to the map document. If it's not in a shared location, carefully type the path of the map document. For example: "C:\Program Files\ArcGIS\DeveloperKit\SamplesNET\Server\data\SanFranciscoNetwork\SanFrancisco.mxd"
  3. Give your service a name. The name you enter here will be used for both the map service and the network analysis service.

  4. On the second page of the wizard, notice that two capabilities are enabled by default. Mapping is enabled for all map services. Network Analysis is enabled because Manager detected that the map you're publishing has one or more network analysis layers. Publishing a map service with the Network Analysis capability enabled creates an associated network analysis service with the same name. Leave these capabilities checked and click Next to move to the final wizard page.

  5. The final page of the wizard explains that two services will be created and gives their URLs.
  6. Click Finish to publish the services and close the wizard.
  7. After the service has been published, click Services > Organize Services to see the newly created service. The name is SanFrancisco and the capabilities include NAServer, which stands for Network Analyst Server and means that the Network Analysis capability has been enabled for this service.

Consuming the network analysis service

Consuming network analysis services via NAServer requires a custom application. The application can be a Web application or task, another Web service, or even a lightweight Windows application.

Regardless of the type of application, the steps to perform the analysis and use the results are the same:

  1. Get a reference to a network analysis service (NAServer) object either through a MapServer that has an NAServer extension loaded or through an NAServer Web service.
  2. Call NAServer::GetSolverParameters to get the NAServerSolverParams object holding the default parameters.
  3. Set properties on the NAServerSolverParams object to configure how you want the analysis to be performed and what you want returned.
  4. Set network locations (for example, Stops) to use in the analysis.
  5. Call NAServer::Solve passing in the NAServerSolverParams object.
  6. Use the returned NAServerSolverResults object to get the results of the analysis.

Below are some sample applications that can consume the network analysis service that you created.

Web application samples using the Web Application Developer Framework (ADF)

Desktop client samples using the Server API

Desktop client samples using WSDL