You are here: Using SOAP > v2006.1 services > Tutorials and samples > Using Visual Studio 2005 Visual Basic .NET v2006.1

T U T O R I A L

Using Visual Studio (Visual Basic .NET) with ArcWeb Services v2006.1

The purpose of this quick-start tutorial is to demonstrate how to access ArcWeb Services with Visual Basic .NET using Visual Studio 2005.

The sample uses Authentication Web Service and Address Finder Web Service as examples of how to use Visual Basic .NET to call ArcWeb Services. ArcWeb Authentication Web Service requires that you send it a request for a validation token prior to accessing an ArcWeb service. You then use this returned token to send your geocoding request to Address Finder Web Service. In this sample, a user enters a series of addresses to be geocoded until the authentication token expires, at which point the client requests a new token from the Authentication Web Service.

Requirements

This tutorial assumes you have the following:

Overview

Download the sample code.

The following steps guide you through sending two requests to ArcWeb Services.

In the first request, you call Authentication Web Service with the following method:

getCustomExpirationToken(username:string, password:string, expiration:integer):string

Included in your request is your user name (username), password (password), and the minutes until the token should expire (expiration). Authentication Web Service returns a token (string) that validates you as an authorized ArcWeb Services user. Use this token to access Address Finder Web Service.

In the second request, you call Address Finder Web Service with the following method:

findLocationByAddress(address:Address, addressFinderOptions:AddressFinderOptions, token:string):GeocodeInfo

Included in your request are two objects (Address and AddressFinderOptions) and the token from the Authentication Web Service. Address Finder Web Service returns a list of geocoded matches for the address that correspond to the input argument.

How to use Visual Basic .NET

  1. Open Visual Studio 2005.
  2. Click File, click New, and select Project.
  3. Click Visual VB under Other Languages, then click Console Application under Templates.
  4. Substitute the module Module1 with the sample code below. NOTE: The downloadable ZIP file contains the same sample code.
  5. Imports Au = ConsoleApplication1.Authentication
    	
    	Imports Af = ConsoleApplication1.AddressFinder
    	
    	Module Module1
    	Sub Main()
    	
    	    Dim username = "USERNAME"  'Replace with your ArcWeb usernameDim password = "PASSWORD"  'Replace with your ArcWeb PasswordDim expiration = 60
    	
    	    Try'Create an instance of the AuthenticationDim  AuthenticationInstance As Au.Authentication
    	
    	        AuthenticationInstance = New Au.Authentication
    	
    	        'Create an instance of the AddressFinderDim AddressFinderInstance As Af.AddressFinder
    	
    	        AddressFinderInstance = New Af.AddressFinder
    	
    	        'Request a token from the Authentication Web Service Dim token As String
    	
    	        '---------------Call the Authentication WebService ----------------- token = AuthenticationInstance.getCustomExpirationToken(username, password, expiration)
    	
    	        'Create an instance of Address, the definition of the address or intersection to be located.Dim myAddress As Af.Address
    	
    	        myAddress = New Af.Address
    	
    	        myAddress.houseNumber = "380"
    	
    	        myAddress.street = "NewYork Street"
    	
    	        myAddress.city = "Redlands"
    	
    	        myAddress.stateProvince = "CA"
    	
    	        myAddress.postalCode = "92373"
    	
    	        myAddress.country = "US"
    	
    	        'Create an instance of AddressFinderOptionsDim myAddressFinderOptions As New Af.AddressFinderOptions
    	
    	        myAddressFinderOptions.dataSource = "ArcWeb:TA.Streets.US"
    	
    	        '---------------Call the AddressFinder WebService - findLocationByAddress method-----------Dim myGeocodeInfo As New Af.GeocodeInfo
    	
    	        myGeocodeInfo = AddressFinderInstance.findLocationByAddress(myAddress, myAddressFinderOptions, token)
    	
    	        '--------------- Display the results from the webService------------Dim myGeocodeCandidate As Af.GeocodeCandidate
    	
    	        ' Get the first candidate from the resultmyGeocodeCandidate = myGeocodeInfo.candidates(0)
    	
    	        ' Print the resultConsole.WriteLine(myGeocodeCandidate.desc1) 'Address description1 Console.WriteLine("(" + (myGeocodeCandidate.point.x).ToString + "," + (myGeocodeCandidate.point.y).ToString + " ) ") ' Lon/lat of addressConsole.WriteLine("Match Type = " + myGeocodeCandidate.matchType) ' Address MatchType Console.ReadLine() ' Does nothingCatch e As Exception ' print any exception
  6. Replace USERNAME and PASSWORD with your ESRI Global Account user name and password.

    NOTE: Your account must be activated for ArcWeb Services.

  7. Add a Web reference for the Authentication Web Service to the new console application. This step creates a proxy class on the client computer. After the proxy class exists, you can create objects based on the class. Each method call that is made with the object then goes out to the URL of the ArcWeb Service, usually as a SOAP request.
    1. Click Project and click Add Web Reference.
    2. In the Add Web Reference dialog box, type the URL for the Authentication Web Service in the Address text box (https://www.arcwebservices.com/services/v2006_1/Authentication?wsdl) and press Enter.
    3. Change Web Reference name to Authentication.
    4. Click Add Reference.

    NOTE: You may receive the following warning: "Schema validation warning: Schema item 'complexType' named 'GeocodeCandidate' from namespace 'http://www.arcwebservices.com/v2006_1/com.esri.aws.dto/' is invalid. Namespace 'http://www.arcwebservices.com/v2006_1/com.esri.aws.dto.geom/' is not available to be referenced in this schema." This warning does not affect the functionality of either service and the AddressFinder and Authentication services will work without problems.

  8. Repeat step 6 for Address Finder Web Service with name as AddressFinder (http://www.arcwebservices.com/services/v2006_1/AddressFinder?wsdl).
  9. Include a separate Imports statement at the top of your code window for each of the namespaces of AddressFinder and Authentication that are in your Console Application.

    HINT: You can see the names of the namespaces in solution view (View > Solution View, then double-click Web References to see the names of the namespaces). Use the format Imports [project name].[namespace], for example:

    Imports ConsoleApplication1.Authentication

  10. Click Build on the Build menu to build the console application.
  11. Click Debug and click Start to test the application.
  12. Save and close the project.

Visit the Feedback page to give comments or suggestions about the ArcWeb Developer's Guide.

ArcWeb site | ArcWeb support | support.esri.com

Copyright © ESRI