simpleWS
DESCRIPTION:
This defines a class that can simplifies creating Web Services. It inherits from soap2r’s SOAP::RPC::StandaloneServer and provides a few enhancements, the most important the fact that it is able to produce the WSDL automatically.
FEATURES/PROBLEMS:
SYNOPSIS:
Each Web Service provided is described using the method ‘serve’, which takes as arguments the name of the service, the name of its arguments, the type of its arguments and an optional block of code. If a block of code is provided, it will be the one executed when the service is called, if not, a function with the same name will be used. The types for the arguments are listed here, along with the WSDL type that it is translated to:
:string => ‘xsd:string’, :integer => ‘xsd:integer’, :array => ‘tns:ArrayOfString’, :hash => ‘tns:Map’, :binary => ‘xsd:base64Binary’,
The type of the result value may also be specified using the name :return, this means no argument may be called :return. If it is not specified there will be no return value.
Following is an example of use:
class TestWS < SimpleWS
def hi(name)
"Hi #{name}, how are you?"
end
def initialize(*args)
super(*args)
serve :hi, %(name), :name => :string, :return => :string
serve :bye, %(name), :name => :string, :return => :string do |name
"Bye bye #{name}. See you soon."
end
end
end
The constructor accepts a number of parameters. The name of the server, a description, the host and the port, along with any other arguments one wishes to pass to the SOAP::RPC::StandaloneServer constructor
This is an example of instantiating the above server:
server = TestWS.new(“TestWS”, “Greeting Services”, ‘localhost’, ‘1984’) server.wsdl(“TestWS.wsdl”)
The function ‘wsdl’ saves the WSDL describing the services and the location provided as an argument.
REQUIREMENTS:
Requires soap4r gem to be installed.
INSTALL:
sudo gem install simpleWS
LICENSE:
(The MIT License)
Copyright © 2008 Miguel Vazquez ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.