Making an XML-RPC-Enabled Program : xmlrpc « Network « Ruby

Making an XML-RPC-Enabled Program

require 'xmlrpc/server'

server =
server.add_handler("sample.sumAndDifference") do |a,b|
  { "sum" => a.to_i + b.to_i,
    "difference" => a.to_i - b.to_i }

trap("INT") { server.shutdown }

# The following client could use the sample.sumAndDifference method made available by the preceding server:
require 'xmlrpc/client'

server = XMLRPC::Client.new2("")
puts"sample.sumAndDifference", 5, 3).inspect


Related examples in the same category

1.Writing XML-RPC Clients
2.XMLRPC call
3.XMLRPC client
4.Writing XML-RPC Servers
5.Dumping and Loading XML-RPC Messages
6.Calling a method made available over XML-RPC
7.process errors that come back from RPC calls with call2