- require 'soap/rpc/standaloneServer'
- class MyServer < SOAP::RPC::StandaloneServer
- def initialize(*args)
- super
- add_method(self, 'sayhelloto', 'username')
- end
- def sayhelloto(username)
- "Hello, #{username}."
- end
- end
- server = MyServer.new('CoolServer','urn:mySoapServer','localhost',8888)
- trap('INT') { server.shutdown }
- server.start
- # Call your service
- require 'soap/rpc/driver'
- driver = SOAP::RPC::Driver.new('<a href="http://localhost:8888/">http://localhost:8888/', 'urn:mySoapServer')
- driver.add_method('sayhelloto', 'username')
- driver.sayhelloto('aaa')
- #该片段来自于http://www.codesnippet.cn/detail/050120131315.html
来源: http://www.codesnippet.cn/detail/050120131315.html