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. This tutorial assumes you have ColdFusion MX 7 running on your machine and an activated ArcWeb account.
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 an 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.
|
|
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:
webservice: The URL of the ArcWeb service, also known as the WSDL location.
method: The request to the ArcWeb service. Each ArcWeb service has several methods.
returnvariable: Name of the variable that contains your requested information from the Web service. It is also known as the response. In ArcWeb Services, you can see the returnvariable at the end of each method.
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 user. Use this token to access Address Finder Web Service.
webservice: https://www.arcwebservices.com/services/v2006/Authentication.wsdl
method: getCustomExpirationToken(username:string, password:string, expiration:integer):string
returnvariable: token
Consuming Address Finder Web Service
You send Address Finder two objects (Address and AddressFinderOptions) and the token from the Authentication Web Service. Address Finder then returns a list of geocoded matches for the address that match the input argument.
webservice: http://www.arcwebservices.com/services/v2006/AddressFinder.wsdl
method: findLocationByAddress(address:Address, addressFinderOptions:AddressFinderOptions, token:string):GeocodeInfo
returnvariable: GeocodeInfo
<html>
<head>
<title>ArcWeb Services Tutorial</title>
</head>
<body>
<cfset username = "USERNAME"> <!--- Replace with your
ArcWeb username--->
<cfset password = "PASSWORD"> <!--- Replace with your
ArcWeb password--->
<cfset expiration = 60> <!--- in minutes--->
<!---***************** Invoke Authentication Web service****************--->
<cftry>
<cfinvoke
webservice = "https://www.arcwebservices.com/services/v2006/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/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>
c:/inetpub/wwwroot (This is the default IIS default.)
http://localhost/awsample.cfm
Visit the Feedback page to give comments or suggestions about the ArcWeb Developer's Guide.