I have a university assignement, and i am stuck. I am supposed to create
a server using xml-rpc with ruby, but I keep getting errors. I am not
very good with ruby, this is actually the first time im working on a
ruby assignement.
The goal is to in the end create 3 client/server programs in 3 different
languages:ruby,c# and java and to have them communicate. sadly i cant
even get it to communicate from ruby to ruby.
here is my server :
require 'webrick'
require 'xmlrpc/server.rb'
class Something<XMLRPC::WEBrickServlet
def initialise()
# create a servlet to handle XML-RPC requests:
servlet = XMLRPC::WEBrickServlet.new
servlet.add_handler("upper_case") { |a_string| a_string.upcase }
servlet.add_handler("help"){|| puts "print some string"}
servlet.add_handler("lower_case") { |a_string| a_string.downcase }
# create a WEBrick instance to host this servlet:
server=WEBrick::HTTPServer.new(:Port => 9090)
trap("INT"){ server.shutdown }
server.mount("/RPC2", servlet)
server.start
end
here is my client:
require 'xmlrpc/client'
server = XMLRPC::Client.new("127.0.0.1", "/RPC2", 9090)
puts server.call("upper_case", "abcd")
puts server.call("lower_case", "HELLO")
server.call("help")
the calls for upper and lower case work fine, but if i want to just puts
a string on the screen, it doesnt seem to work.
C:\Users\Moog\Ruby>xmlclient.rb
ABCD
hello
C:/Ruby192/lib/ruby/1.9.1/xmlrpc/client.rb:549:in `do_rpc': HTTP-Error:
500 Inte
rnal Server Error (RuntimeError)
from C:/Ruby192/lib/ruby/1.9.1/xmlrpc/client.rb:420:in `call2'
from C:/Ruby192/lib/ruby/1.9.1/xmlrpc/client.rb:410:in `call'
from C:/Users/Moog/Ruby/xmlclient.rb:6:in `<main>'
I am completely stuck on this. All help would be greatly appreciated.
···
--
Posted via http://www.ruby-forum.com/.