On Mon, 2002-10-21 at 17:57, Daniel Berger wrote:
> Hi all,
> 
> Ruby 1.6.7, REXML 2.4.2, Sys/ProcTable 3.1, XML-RPC 1.7.11
> 
> I'm getting the dreaded "Internal Server Error" when I try to return an
> array of structs within a handler.
> 
> Here's the code:
> 
> require "xmlrpc/server"
> require "sys/proctable"
> include Sys
> 
> class Test
>    def add(a,b)
>       a + b
>    end
> 
>    def ps
>       a = []
>       a = ProcTable.ps # This fails
>       #ProcTable.ps{|struct| a.push(struct.pid)} # This works
>       return a
>    end
> end
> 
> server = XMLRPC::Server.new(8889,"1.2.3.4",4,$stdout) # Use a real IP
> server.add_handler("test",Test.new)
> server.serve

Is ProcTable.ps really of type "Struct"? Or is it an object of an
user-defined class? 

Does ProcTable.ps return nil under some circumstances.

If that doesn't help, please send me the definition of ProcTable.ps.


> The ProcTable.ps call returns an array of structs in lvalue context, and
> that seems to be the problem.  I also tried just returning a list of
> pid's and that worked fine.  The "add" method also works fine (I just
> threw that in for testing purposes).
> 
> Here's the actual client code:
> 
> require "xmlrpc/client"
> 
> client = XMLRPC::Client.new("1.2.3.4",nil,8889) # Use a real IP
> 
> begin
>    v = client.call("test.ps")
> rescue RuntimeError => e
>    puts "Error:"
>    puts e.faultCode
>    puts e.faultString
> rescue XMLRPC::FaultException => e

Should be:

rescue XMLRPC::FaultStructure => e


>    puts "Error:"
>    puts e.faultCode
>    puts e.faultString
> end
> 
> Here's the RuntimeError message:
> 
> >ruby xmlrpcClientTest.rb
> Error:
> xmlrpcClientTest.rb:9: undefined method `faultCode' for
> #<RuntimeError:0x15bb30> (NameError)
> 
> Any ideas?

You call faultCode on a RuntimeError! See above.

Regards,

  Michael