【发布时间】:2023-03-10 21:04:01
【问题描述】:
我有下一个代码
require 'rack/rpc'
class Server < Rack::RPC::Server
def hello_world
"Hello, world!"
end
rpc 'hello_world' => :hello_world
end
server = Server.new
use Rack::RPC::Endpoint, server
run server
脚本名称是 server.ru
我正在使用命令启动服务器
thin start -R server.ru
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
也是客户端示例
require "xmlrpc/client"
# Make an object to represent the XML-RPC server.
server = XMLRPC::Client.new( "0.0.0.0", "/rpc", 3000)
# Call the remote server and get our result
result = server.call("hello_word")
puts result
下一个命令给了我异常
ruby client.rb
client.rb:414:in `call': Method hello_word missing or wrong number of parameters! (XMLRPC::FaultException)
from client.rb:7:in `<main>'
为什么找不到 hello_word?谢谢。
【问题讨论】:
-
改变你原来的问题有什么意义,这样实际的问题就不再存在了?