T U T O R I A L S
In this tutorial, we will create an ASP.NET
Web application in Microsoft Visual Studio 2008 to consume an ArcGIS Server
Web 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 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.
Sample code for this tutorial is available here: SharedTypes.zip
Generate the Web service proxies and shared value objects
Open a Visual Studio 2008 command prompt and type "wsdl.exe". Note the help content returned in the console.
Create a temp directory (e.g. c:\temp) and create a text file in the directory named "sharedsoaptypes.bat".
Open the text file
in a text editor (e.g. notepad) and add the following line. This
line 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/arcgis/services/MapService/MapServer?wsdl
http://localhost/arcgis/services/GeocodeService/GeocodeServer?wsdl http://localhost/arcgis/services/Geometry/GeometryServer?wsdl
The following command line parameters are used:
Parameter |
Description |
/sharetypes |
Create one type for all common type definitions in each defined wsdl
|
/language:CS |
The language of the
class file generated by this command. |
/namespace:SharedNamespace |
The namespace of the proxies and value object types in the generated class file. |
/out:.\ArcGISSOAP_SharedTypes.cs |
The name of the class
file containing the proxies and value objects generated from each defined
wsdl |
/protocol:SOAP |
The protocol format of the Web requests generated by the proxies and value objects.
|
*.wsdl |
The path or url to one or more wsdls used to generate native .NET class file.
|
Confirm that three
ArcGIS Server Web services are available: a map, geocode, and geometry
service. 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.
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.
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
In Visual Studio 2008, click File, New Web Site.
In the New Web Site dialog, select the .NET Framework 3.5 option.
Under Templates, select ASP.NET Web Site.
The Location setting can be File System or HTTP. In this tutorial, we will use File System.
The Language setting can be C# or VB.NET. In this tutorial, we will use C#.
Specify
a path to the new Web Site and name the project "SOAPSharedTypes".
Add library with proxies and shared value object types
In the Solution Explorer window, right click the Web project and select "Add Reference...".
In
the Add Reference dialog, select 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.