180 likes | 308 Views
Discover the evolution of web data consumption with insights from Michael Dinowitz, head of House of Fusion and a founding member of Team Macromedia. Dive into the intricacies of using ColdFusion for web services like Amazon, eBay, and Google, while understanding data formatting for humans. Explore screen scraping, RESTful APIs, and SOAP web services. Learn how to use CFHTTP for data retrieval, XML parsing, and invoking web services efficiently. This guide is essential for developers looking to streamline data processes and enhance software applications.
E N D
Consuming popular web services Amazon, Ebay and Google at your fingertips
Who am I • Michael Dinowitz • Head of House of Fusion • Publisher of Fusion Authority • Founding member of Team Macromedia • Using ColdFusion since June 1995
Evolution • Web is data formatted for humans • For humans by humans • Good for people, bad for software • Need to ‘transfer’ data by hand
Evolution • Screen Scraping • Removing UI and ‘human’ layer from data • Complex • Breaks on any change to UI
Evolution • CFHTTP to get the data • RegEx to parse it • sItem=REFindNoCase('<a href="http://cgi\.ebay\.com/ws/eBayISAPI\.dll\?ViewItem&category=([0-9]+)&item=([0-9]+)[^>]+>([^<]+)</a>[^\$]+(\$[^<]+)<[^%]+%[^%]+%[^:]+([a-z]{3,5}-[0-9]+)[^:]+:', CFHTTP.FileContent, Start, 1)
Next level • Remove people from the equation • Content for software by software • Data in XML over HTTP • Referred to as REST (Representational State Transfer) • Not complex at all
REST • CFHTTP to get content • XML functions to parse content • http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=coldfusion&results=20 • Example Code
Segue • PaypalMX – Paypal web services • http://www.web-relevant.com/ • Uses REST – multipart REST • Paypal REST is overly complex • Soap is ‘cleaner’ here • What is SOAP?
SOAP • Simple Object Access Protocol • Object like access to web services • Overly complex in ways • Connects to a WSDL template • Web Services Description Language • Still XML, but ‘hidden’
Basics: Connect • Uses CFINVOKE, CFOBJECT or CreateObject() to connect
CFINVOKE • Calls a web service directly • Uses CFINVOKEARGUMENT to pass arguments • Returns a single variable • One method call per invoke
CFINVOKE Example • <cfinvoke • webservice="http://www.xmethods.net/sd/2001/TemperatureService.wsdl" • method="getTemp" • returnvariable="aTemp"> • <cfinvokeargument name="zipcode" value="55987"> • </cfinvoke> • <cfoutput>The temperature is #aTemp#</cfoutput>
CreateObject() Example • Connects to service • Calls methods separately • Can invoke multiple methods per connection • <cfscript> • ws = CreateObject("webservice", "http://www.xmethods.net/sd/2001/TemperatureService.wsdl"); xlatstring = ws.getTemp(zipcode = "55987"); • writeoutput("The temperature is " & xlatstring); </cfscript>
CFOBJECT • Same as CreateObject() but uses the tag
Issues • Security • Getting service ID from vendor • Read the docs!!!!