Bruno Miranda's Notebook

Personal Blog about Ruby on Rails, XHTML, CSS, and Design

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
Comments: 0 (view/add your own) Tags: XMLRPC, ruby