We Recommend

Beginning Ruby: From Novice to Professional Beginning Ruby: From Novice to Professional
Beginning Ruby is a thoroughly contemporary guide for every type of reader wanting to learn Ruby, from novice programmers to web developers to Ruby newcomers. It starts by explaining the principles behind object-oriented programming and within a few chapters builds toward creating a genuine Ruby application.


Posted By

chrisaiv on 10/21/07


Tagged

rpc


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

zemariamm
riz


XML-RPC (Remote Procedure Calls)


Published in: Ruby 


RPC is an alternative to SOAP or REST. If you find a webservice that has an implementation, here is are a few ways to make it work using Ruby

  1. #Example 1: Find a State in a Specific Sort Order
  2. #A. Import the XMLPRC Library (Thanx Michael Nuemann)
  3. require 'xmlrpc/client'
  4. #B. You have to define the web address that will run the RPC against
  5. server = XMLRPC::Client.new2('http://betty.userland.com/RPC2')
  6. puts server.call('examples.getStateName', 1)
  7.  
  8. #Example 2: Find product information based on a UPC number
  9. #C. You have to define the web address that will run the RPC against
  10. server = XMLRPC::Client.new2('http://dev.upcdatabase.com/rpc')
  11. #D. lookupUPC is a method, the number is a product UPC
  12. @item = server.call('lookupUPC', '720642442524')
  13. #E. Store the result in an array
  14. p @item
  15. puts "Description :: " + @item["description"]
  16. puts "Type :: " + @item["size"]

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: sabigual on September 4, 2008

Where are the library??

Posted By: sabigual on September 4, 2008

Where are the library??

You need to login to post a comment.