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.
Publish a network analysis service
- Open ArcMap.
- Open <Your ArcGIS Developer Kit install folder>\samples\data\SanFrancisco\SanFrancisco.mxd.
- Navigate to File > Share As > Service.
- Choose Publish a service, and click Next.
- Choose Publisher connection to ArcGIS 10.1 Server, which will host the published document.
- Click Next, then click Continue.
- Choose Capabilities, and check the Network Analysis check box.
- Click the Analyze button and address any significant issues that may be present.
- Click the Publish button. Note: If the publishing connection does not have "Copy data to the server when publishing" selected, SanFrancisco.gdb should be present on the server in exactly the same location as on the publishing machine.
Publish a geocoding service
- Open the Catalog window in ArcMap, navigate to SanFrancisco.gdb, right-click SanFranciscoLocator, and click Share As > Geocode Service.
- Type SanFranciscoLocator as the service name and click Next.
- Choose Publish a service, and click Next.
- Choose Publisher connection to ArcGIS 10.1 Server, which will host the published document.
- Click Next, then click Continue.
- Click Publish.
Add a reference to the service to your .NET solution
- Start Visual Studio.
- Open the solution file.
- In the Solution Explorer, right-click References and choose Add Web Reference.
- Type the following URL: http://<server>:6080/arcgis/services/SanFrancisco/MapServer/NAServer?wsdl, then click Go.
- Change the Web reference name to WebService.
- Click Add Reference.
- Save the solution.
- Close Visual Studio.
Merge Web Service Description Languages (WSDLs) from NAServer and GeocodeServer
- Open a Visual Studio command prompt.
- Change to the directory where the proxy stub file was generated, <Solution Folder>\Web References\WebService.
- For C#, type the following: wsdl.exe /Language:cs /verbose /sharetypes /namespace:GeocodeRoute_WebService.WebService /out:Reference.cs http://<server>:6080/arcgis/services/SanFrancisco/MapServer/NAServer?wsdl http://<server>:6080/arcgis/services/SanFranciscoLocator/GeocodeServer?wsdl
- For VB .NET, type the following (change localhost if ArcGIS for Server is on a different machine): wsdl.exe /Language:VB /verbose /sharetypes /namespace:GeocodeRoute_WebService.WebService /out:Reference.vb http://<server>:6080/arcgis/services/SanFrancisco/MapServer/NAServer?wsdl http://<server>:6080/arcgis/services/SanFranciscoLocator/GeocodeServer?wsdl
Run the sample
- Open the solution file in Visual Studio.
- Build and run the project.
- Choose the route solver options.
- Click the Find Route button.
- Click the different tabs to get the solver results.
GeocodeRoute_WebServiceClass.cs | Code for the main form. |
GeocodeRoute_WebServiceClass.resx | Resource file. |
GeocodeRoute_WebServiceClass.vb | Code for the main form. |
GeocodeRoute_WebServiceClass.resx | Resource file. |
Download the files for all languages
Development licensing | Deployment licensing |
---|---|
Engine Developer Kit | Engine: Network Analyst |
ArcGIS for Desktop Basic: Network Analyst | ArcGIS for Desktop Basic: Network Analyst |
ArcGIS for Desktop Standard: Network Analyst | ArcGIS for Desktop Standard: Network Analyst |
ArcGIS for Desktop Advanced: Network Analyst | ArcGIS for Desktop Advanced: Network Analyst |