Xmlrpc (working on mac, not on linux, why?)


#1

I’m guessing I missed some install, but I can’t find out what because
the error.

OSX ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
RHEL4 ruby 1.8.3 (2005-09-21) [i386-linux]

ERROR LoadError: no such file to load – rexml/namespace
where do I get that?

same script teaching myself xmlrpc on both OSX and RHEL4

server:

#!/usr/bin/ruby
require ‘webrick’
require ‘xmlrpc/server.rb’

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(“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

Client:

#!/usr/bin/ruby
require ‘xmlrpc/client’
server = XMLRPC::Client.new(“127.0.0.1”, “/RPC2”, 9090)
puts server.call(“upper_case”, “The fat dog chased the cat on Elm
Street.”)
puts server.call(“lower_case”, “The fat dog chased the cat on Elm
Street.”)

running this on linux I get
[root@adml-v01 agent]# ./s1
[2007-02-21 13:49:47] INFO WEBrick 1.3.1
[2007-02-21 13:49:47] INFO ruby 1.8.3 (2005-09-21) [i386-linux]
[2007-02-21 13:49:47] INFO WEBrick::HTTPServer#start: pid=17086
port=9090

localhost.localdomain - - [21/Feb/2007:13:50:07 EST] “POST /RPC2
HTTP/1.1” 200 0

  • -> /RPC2
    [2007-02-21 13:50:07] ERROR LoadError: no such file to load –
    rexml/namespace
    /usr/lib/ruby/1.8/rexml/element.rb:2:in require' /usr/lib/ruby/1.8/rexml/element.rb:2 /usr/lib/ruby/1.8/rexml/document.rb:1 /usr/lib/ruby/1.8/xmlrpc/parser.rb:700:ininitialize’
    /usr/lib/ruby/1.8/xmlrpc/utils.rb:48:in parser' /usr/lib/ruby/1.8/xmlrpc/server.rb:309:inprocess’
    /usr/lib/ruby/1.8/xmlrpc/server.rb:760:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
    /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
    /usr/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:instart’
    /usr/lib/ruby/1.8/webrick/server.rb:92:in start' /usr/lib/ruby/1.8/webrick/server.rb:23:instart’
    /usr/lib/ruby/1.8/webrick/server.rb:82:in start' ./s1:14 /usr/lib/ruby/1.8/xmlrpc/utils.rb:159:inparse_content_type’: private
    method split' called for nil:NilClass (NoMethodError) from /usr/lib/ruby/1.8/xmlrpc/client.rb:549:indo_rpc’
    from /usr/lib/ruby/1.8/xmlrpc/client.rb:420:in call2' from /usr/lib/ruby/1.8/xmlrpc/client.rb:410:incall’
    from ./c1:4

HUH?