Cerise supports publishing Ruby objects as SOAP services, including the automatic generation of WSDL. At the moment only simple input parameter and return types are supported by the WSDL generator. An example application using cerise's SOAP support is included in cerise/apps/soap
Creating a class to be published as a service is a simple task of
extending Cerise::WebService and adding a
remote(...) line for each of the methods to be
published. The following example defines a simple service which
takes a String and returns a new String that includes the input:
class EchoService < Cerise::WebService
def echo(str)
return ">#{str}<"
end
remote(:echo, [:str, String], String)
end
A SOAP service must be threadsafe since a single instance is published,
and receives all calls. It must also have a zero parameter constructor
since ServiceClass.new() is called.
Cerise::SoapHandler passes HTTP requests from
cerise to SOAP4R. It expects a request path ending with the class name
of the service to invoke. If the class name includes .wsdl on
the end then a WSDL document is generated for that service. If there is
no .wsdl then the request is treated as an invocation of the
service and must be a POST with the body including a SOAP request.
To get WSDL: http://localhost:8000/soap/EchoService.wsdl
To invoke: http://localhost:8000/soap/EchoService
To use Cerise::SOAPHandler in a cerise application, you
need to add require 'soap' to your app.cfg. This library
is not automatically loaded by cerise, see cerise/apps/soap/app.cfg
for an example. The following configuration parameters are supported:
| parameter | description |
|---|---|
| :namespace | the XML namespace to use when generating WSDL for services |