Writing a SOAP Server
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('http://localhost:8888/', 'urn:mySoapServer')
driver.add_method('sayhelloto', 'username')
driver.sayhelloto('aaa')
Related examples in the same category