2,764
社区成员




class HelloWorld
attr_reader :hello
def initialize
@hello = "Hello Ruby Web Services!!"
end
def printToScreen(str)
puts str
end
end
require 'soap/rpc/standaloneServer'
require 'HelloWorld'
NS = "http://test.websoft.com/hello"
class Server2 < SOAP::RPC::StandaloneServer
def on_init
hello = HelloWorld.new
add_method(hello, 'hello')
add_method(hello, "printToScreen", 'str')
end
end
svr = Server2.new('hello', NS, '0.0.0.0', 3000)
trap('INT') { svr.shutdown }
svr.start
require 'soap/rpc/driver'
proxy = SOAP::RPC::Driver.new("http://localhost:3000",
"http://test.websoft.com/hello")
proxy.add_method('hello')
proxy.add_method('printToScreen', 'str')
puts "#{ proxy.hello }"
proxy.printToScreen("Test for Web Services !!")