Writing XML-RPC Servers : xmlrpc « Network « Ruby






Writing XML-RPC Servers


require "xmlrpc/server"

class Num
  INTERFACE = XMLRPC::interface("num") {
    meth 'int add(int, int)', 'Add two numbers', 'add'
    meth 'int div(int, int)', 'Divide two numbers'
  }

  def add(a, b) a + b end
  def div(a, b) a / b end
end

server = XMLRPC::Server.new(8080, "0.0.0.0")
server.add_handler(Num::INTERFACE, Num.new)
server.serve

 








Related examples in the same category

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