From: Fengfeng Li Date: 2012-07-18T11:04:36+09:00 Subject: How can soap client call methods in a free way? Hi everyone, I'm new to soap, I wonder how to call methods as free as if all the objects are local? To explain my question, I attached my code, please help me to look into it. Thanks a lot. And what's more, I searched the web and there's too little infomation about ruby soap, have you guys switched to REST or sth else? ==========Server code is as below require 'soap/rpc/standaloneServer' module MySOAP class Test1 def initialize @a = 1 @b = 2 end def test1 @a+@b end end class Test2 def test2 Test1.new end end end class TimeServer < SOAP::RPC::StandaloneServer def on_init test1 = MySOAP::Test1.new test2 = MySOAP::Test2.new add_method(test1, "test1") add_method(test2, "test2") end end NS = 'http://localhost/soap' port = 12321 svr = TimeServer.new('timer',NS,'0.0.0.0',port) trap('INT') { svr.shutdown } puts "My SOAP is starting... port:#{port} (Ctrl+c to quit)" svr.start puts "My SOAP is stop." ===========And Client code is like this: require 'pp' require 'soap/rpc/driver' proxy = SOAP::RPC::Driver.new("http://localhost:12321", "http://localhost/soap") proxy.add_method('test1') proxy.add_method('test2') pp proxy a = proxy.test2 a.test1 ====> I can only call proxy.test1 but can't call a.test1? a is a Test1 object. -- Posted via http://www.ruby-forum.com/.