You are here: Using SOAP > v2006.1 services > Tutorials and samples > Using ColdFusion with ArcWeb Services v2006.1

T U T O R I A L

Using ColdFusion MX with ArcWeb Services v2006.1

The purpose of this quick-start tutorial is to demonstrate how to access ArcWeb Services using ColdFusion MX 7. ColdFusion MX is Macromedia product for developing and consuming Web services. ArcWeb has tested this tutorial with ColdFusion MX 7.0.1 and ColdFusion MX 7 with ColdFusion MX 7 Updater.

The sample uses Authentication Web Service and Address Finder Web Service as examples of how to use ColdFusion MX to call ArcWeb Services. ArcWeb Authentication Web Service requires that you send it a request for a validation token prior to accessing any 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.

Using cfinvoke tag

This tutorial shows you how to use the cfinvoke tag to consume Authentication Web Service and Address Finder Web Service in ColdFusion. To consume these services, you need to supply the following attribute information:

Consuming Authentication Web Service

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

Consuming Address Finder Web Service

You send Address Finder Web Service two objects (Address and AddressFinderOptions) and the token from the Authentication Web Service. Address Finder Web Service then returns a list of geocoded matches for the address that correspond to the input argument.

How to use ColdFusion MX

  1. Create a new document using HomeSite, DreamWeaver, or a text editor such as Notepad.  
  2. Copy and paste the sample code below. NOTE: The downloadable ZIP file contains the same sample code.

<html>
<head>
<title>ArcWeb Services Tutorial</title>
</head>

<body>
<cfset username = "USERNAME"> <!--- Replace with your ESRI Global Account user name--->
<cfset password = "PASSWORD"> <!--- Replace with your ESRI Global Account password--->
<cfset expiration = 60> <!--- in minutes--->

<!---***************** Invoke Authentication Web Service****************--->


<cftry>
<cfinvoke  
webservice = "https://www.arcwebservices.com/services/v2006_1/Authentication?wsdl"
method="getCustomExpirationToken"
returnVariable = "token">
<cfinvokeargument name="Username" value=#username#>
<cfinvokeargument name="Password" value=#password#>
<cfinvokeargument name="expiration" value=60>
</cfinvoke>

<!--- Address --->

<cfset myAddress = structNew()>
<cfset myaddress.City = "Redlands">
<cfset myAddress.Country = "US">
<cfset myAddress.HouseNumber = "380">
<cfset myAddress.PostalCode = "92373">
<cfset myAddress.StateProvince = "CA">
<cfset myAddress.Street = "New York Street">

<!--- AddressFinderOptions --->

<cfset myAddressFinderOptions = structNew()>
<cfset myAddressFinderOptions.DataSource = "ArcWeb:TA.Streets.US">
<cfset myAddressFinderOptions.PartialAddress = true>
 
<!---***************** Invoke Address Finder Web Service****************--->


<cfinvoke  
webservice = "http://www.arcwebservices.com/services/v2006_1/AddressFinder?wsdl"
method="findLocationByAddress"
returnVariable = "myGeocodeInfo">
<cfinvokeargument name="Address" value=#myAddress#>
<cfinvokeargument name="AddressFinderOptions" value=#myAddressFinderOptions#>
<cfinvokeargument name="Token" value=#token#>
</cfinvoke>

<!---***************** Display results ****************--->


<cfoutput>
<cfset myArrayOfGeocodeCandidate = #myGeocodeInfo.candidates#>
<cfset myGeocodeCandidate = #myArrayOfGeocodeCandidate.geocodecandidate#>
 

<!--- Print the location and description of the first candidate --->
<br>Description = #myGeocodeCandidate[1].desc1#
<br>Location (x,y) = (#myGeocodeCandidate[1].point.x#, #myGeocodeCandidate[1].point.y#)  
</cfoutput>

<cfcatch type="Any">
<cfoutput>#cfcatch.message#</cfoutput>
</cfcatch>
</cftry>

</body>
</html>

  1. Replace USERNAME and PASSWORD with your ESRI Global Account user name and password.

    NOTE: Your account must be activated for ArcWeb Services.

  1. Save the file as awsample.cfm under Web root, for example:
  2. c:/inetpub/wwwroot (This is the default IIS location.)

  3. Browse the awsample.cfm, for example:
  4. http://localhost/awsample.cfm


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

ArcWeb site | ArcWeb support | support.esri.com

Copyright © ESRI