Ruby/Network/XML RPC
Материал из Wiki.crossplatform.ru
Call a web service
def lookup_upc(upc) server = XMLRPC::Client.new2("http://www.upcdatabase.ru/rpc") begin response = server.call("lookupUPC", upc) return response["found"] ? response : nil rescue XMLRPC::FaultException => e puts "Error: " puts e.faultCode puts e.faultString end end product = lookup_upc("018787765654") product["description"] product["size"] lookup_upc("no such UPC")
Writing an XML-RPC Client
require "xmlrpc/client" server = XMLRPC::Client.new2("http://yourURL") server.call("yourmethod", 5) begin server.call("noSuchMethod") rescue XMLRPC::FaultException => e puts "Error: fault code #{e.faultCode}" puts e.faultString end