From: Jeremy Bopp Date: 2010-10-07T04:43:25+09:00 Subject: Re: XML-RPC WEBrick problem (error during method invocation) On 10/6/2010 5:13 AM, Nikita Kuznetsov wrote: > 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 > 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 The server code is incomplete. I managed to get something to work and reproduce your problem with a little editing though. Take care to be as accurate as possible when asking for help with code. ;-) > 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 `
' > > I am completely stuck on this. All help would be greatly appreciated. Since this is a school assignment, I'll only say that you're very close to the solution and suggest that you closely watch the output of your server while you run your client. Good luck! -Jeremy