Using multiple services in a single application

Complexity: Beginner Data Requirement: Installed with software Goal: Create a web application that consumes an ArcGIS Server map, geocode, and geometry service.

In this tutorial, you will create an ASP.NET Web application in Microsoft Visual Studio 2008 to consume an ArcGIS Server map, geocode, and geometry service. All services will share the same set of common value object types. The MapServer, GeocodeServer, and GeometryServer proxies and value objects will be created dynamically on the command line using the SOAP toolkit (wsdl.exe) included with the .NET 2.0+ SDK. The application will use the ArcGIS Server SOAP API to draw a map, locate an address, reproject the geocoded point, construct and buffer a polyline, use the buffer to select features in the map service, and draw both the buffer and selected features in a map. ASP.NET web controls are used to host inputs and outputs from ArcGIS Server services and ASP.NET AJAX controls are used to enable asynchronous behavior.

Tutorial data

Sample code for this tutorial is available at:

Generate the web service proxies and shared value objects

  1. Open a Visual Studio 2008 command prompt and type wsdl.exe. Note the help content returned in the console.
  2. Create a temp directory (e.g. c:\temp) and create a text file in the directory named sharedsoaptypes.bat.
  3. Open the text file in a text editor and add the following string. This represents a command which will generate a class file that contains SOAP proxies and value object types for the requested service descriptions (WSDLs).

    wsdl.exe /sharetypes /language:CS /namespace:SharedNamespace /out:.\ArcGISSOAP_SharedTypes.cs /protocol:SOAP http://localhost:6080/arcgis/services/MapService/MapServer?wsdl http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer?wsdl http://localhost:6080/arcgis/services/Geometry/GeometryServer?wsdl

    The following command line parameters are used:




    Create one type for all common type definitions in each defined WSDL.


    The language of the class file generated by this command.


    The namespace of the proxies and value object types in the generated class file.


    The name of the class file containing the proxies and value objects generated from each defined WSDL.


    The protocol format of the Web requests generated by the proxies and value objects.


    The path or URL to one or more WSDLs used to generate a native .NET class file.

  4. Confirm that the map, geocode, and geometry services are available. The map and geocode services should share the same geographic region, but not the same spatial reference (projection). For example, the map service may work with San Francisco data in a geographic coordinate system, while the reference data for the geocode service is a San Francisco streets layer in a California StatePlane projected coordinate system.
  5. Add another line to the text file sharedsoaptypes.bat. The CSharp class compiler csc.exe will be used to compile the class file generated by wsdl.exe into an assembly.

    csc.exe /target:library /out:ArcGISSOAP_SharedTypes.dll ArcGISSOAP_SharedTypes.cs


    The /target parameter defines the output type from the compiler as a library (dll). The /out parameter defines the library name.

  6. Since the file extension of the text file is .bat, you can type the file name sharedsoaptypes.bat on the command line to execute both commands. Upon completion, you should have a file named ArcGISSOAP_SharedTypes.dll in the temp directory you created eariler in this section. This assembly will be referenced by the project created in the next section.

Create the web site project

  1. In Visual Studio 2008, click File > New Web Site.
  2. In the New Web Site dialog, select the .NET Framework 3.5 option.
  3. Under Templates, select ASP.NET Web Site.
  4. The location setting can be File System or HTTP. For the purposes of this tutorial, select File System.
  5. The language setting can be C# or VB.NET. For the purposes of this tutorial, select C#.
  6. Specify a path to the new web site and name the project SOAPSharedTypes.

    New Web Site dialog

Add library with proxies and shared value object types

  1. In the Solution Explorer window, right click the web project and select Add Reference.
  2. In the Add Reference dialog, click the Browse tab and navigate to the ArcGISSOAP_SharedTypes.dll and add it to the project. Now you can use the native .NET types defined in the assembly to communicate with a map, geocode, and geometry service.

    Solution Explorer window