1 / 18

Consuming popular web services

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

umeko
Download Presentation

Consuming popular web services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Consuming popular web services Amazon, Ebay and Google at your fingertips

  2. Who am I • Michael Dinowitz • Head of House of Fusion • Publisher of Fusion Authority • Founding member of Team Macromedia • Using ColdFusion since June 1995

  3. Evolution • Web is data formatted for humans • For humans by humans • Good for people, bad for software • Need to ‘transfer’ data by hand

  4. Evolution • Screen Scraping • Removing UI and ‘human’ layer from data • Complex • Breaks on any change to UI

  5. Evolution • CFHTTP to get the data • RegEx to parse it • sItem=REFindNoCase('<a href="http://cgi\.ebay\.com/ws/eBayISAPI\.dll\?ViewItem&amp;category=([0-9]+)&amp;item=([0-9]+)[^>]+>([^<]+)</a>[^\$]+(\$[^<]+)<[^%]+%[^%]+%[^:]+([a-z]{3,5}-[0-9]+)[^:]+:', CFHTTP.FileContent, Start, 1)

  6. 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

  7. 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

  8. 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?

  9. 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’

  10. Basics: Connect • Uses CFINVOKE, CFOBJECT or CreateObject() to connect

  11. CFINVOKE • Calls a web service directly • Uses CFINVOKEARGUMENT to pass arguments • Returns a single variable • One method call per invoke

  12. 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>

  13. 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>

  14. CFOBJECT • Same as CreateObject() but uses the tag

  15. Issues • Security • Getting service ID from vendor • Read the docs!!!!

  16. Amazon

  17. Google

  18. Ebay

More Related