Topic: Creating an API using XML-RPC library

Hi All,

I want to create a API which will call the server and get the result from the server.
Presently just i have an basic idea on XML-RPC to timplement API's.
Just i tried to implement a simple API called "getSum" which is defined in my controller of the server.

To implement this i have written a client.rb code looks like:
----------------------------------------------------------------------
require "xmlrpc/client"

# Make an object to represent the XML-RPC server.
server = XMLRPC::Client.new2( "http://localhost/search/getSum")
puts "sri"
# Call the remote server and get our result
result = server.call("getSum",1,2)
if result
    puts 'Hey, it worked!'
  else
    puts 'Back to the drawing board...'
  end

#puts result
sum = result["sum"]
puts "Sum: #{sum}"
--------------------------------------------------------------------------
from the above code "http://localhost/search/getSum"
'search' is the controller name and 'getSum' is the method defined in controller.

My server code looks like this:
-----------------------------------------
class SearchController < ApplicationController
def getSum(int num1,int num2)
sum = params[:num1] + params[:num2]
puts sum
return sum
end
----------------------------------------------

I have executed the client code like below on commond prompt:
>ruby client.rb
c:/ruby/lib/ruby/1.8/xmlrpc/client.rb:546:in `do_rpc': HTTP-Error: 500 Internal
Server Error (RuntimeError)
        from c:/ruby/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
        from c:/ruby/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
        from client.rb:7

I am getting the error like HTTP-Error.

Then i looked in the log file of my server code, below error is coming:
------------------------------------------------------------------------
Processing SearchController#getSum (for 127.0.0.1 at 2009-07-02 17:08:00) [POST]
  Parameters: {"methodCall"=>{"methodName"=>"getSum", "params"=>{"param"=>[{"value"=>{"i4"=>"1"}}, {"value"=>{"i4"=>"2"}}]}}}
  SQL (0.0ms)   SET NAMES 'utf8'
  SQL (0.0ms)   SET SQL_AUTO_IS_NULL=0
ArgumentError (wrong number of arguments (0 for 2)):
---------------------------------------------------------

Can any one suggest if i am doing any mistake?
Please suggest me to resolve this problem.

thanks All
Srikanth