BrunoMiranda.com

Personal Blog about Technology, Software Engineering, Design & More

Simple XMLRPC Ruby Example

Posted on May 24, 2007 at 04:18 PM

If you’ve ever wondered how you can access an XMLRPC resource using ruby, the code below displays how to do it.

The snippet returns a hash containing information corresponding to the UPC code we performed the lookup on.

require 'xmlrpc/client'
server = XMLRPC::Client.new2('http://www.upcdatabase.com/rpc')
@resp = server.call('lookupUPC', '099482409463')
puts @resp['description']
puts @resp['upc']

The return value from the above will be:

  • Whole Foods Market 365 Italian Still Mineral Water
  • 099482409463
Tags: XMLRPC, ruby
Hierarchy: next

Comments

There are 0 comments on this post. Post yours →

Post a comment

Required fields in bold.

 

Visit the Archives →