watch this  

the official mrchucho blog


Posted 2006 Feb 08

I was writing another rbot plugin - this time to get forecast data from the NOAA like my Quicksilver plugin [1] - and I needed a good way to get latitude and longitude. A quick search revealed that the Yahoo Maps API provides just such a thing!

Yahoo’s API is REST based, whereas the NOAA uses SOAP. The differences in complexity are significant. Using REST, I simply create a URL. No special software, no WSDL, no libraries. Not even any particularly deep understanding of the underlying technology is required.
    def get_lat_long(loc)
        loc = ERB::Util.u(loc)
That’s it! Now I get back an XML document that I can easily parse with REXML. To do the same thing with SOAP requires a little bit more effort and, to me, doesn’t feel as natural.
class Forecast
    def initialize(lat,long)
    def forecast
        forecast = @forecaster.NDFDgenByDay(
            @lat,@long,"%Y-%m-%d"),2,"24 hourly")
        xml = ("forecast.xml",'w') do |file|
            file < < xml
But, most importantly, you have to use a SOAP client to interact with this service… In the case of Yahoo’s API, I can just type a URL into my browser and get results. This is minor, but can be important when first getting started or when debugging.

1 I’ll post later about the differences in writing this software in Ruby versus Cocoa/Objective-C…

Responses to "REST vs. SOAP"

No responses yet.

Comments are now closed.
atom rss