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.
This tutorial assumes you have the following:
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:
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.
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.
<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>
NOTE: Your account must be activated for ArcWeb Services.
c:/inetpub/wwwroot (This is the default IIS location.)
http://localhost/awsample.cfm
Visit the Feedback page to give comments or suggestions about the ArcWeb Developer's Guide.