Writing a SOAP Server : SOAP « Network « Ruby






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

1.Writing a SOAP Client
2.Using a WSDL File to Make SOAP Calls Easier