Wash Out is very simple SOAP service solution. It allows you to create SOAP services on top of your controllers in 3 steps (see Usage).
gem install wash_out
class TestController < ApplicationController wash_with_soap :my_soap_method => { :in => { 'structure' => { 'foo' => :string }, 'bar' => :integer }, :out => :boolean }
Defined this way method “my_soap_method” will wait for two parameters:
-
‘structure’ will wait for complex type (defined separately in WSDL)
-
‘bar’ will wait for integer (xsd:integer in WSDL)
On the other side it will return boolean (xsd:boolean in WSDL).
To enable routes, add ‘wash_with_soap :test’ to your routes.rb.
At same controller define action “my_soap_method”
def my_soap_method @soap # this will contain data passed by SOAP request end
Parameters are handling by WashOut::Param entity. To get values use ‘value’ and ‘[]’ methods.
To get ‘bar’ parameter:
@soap['bar'].value
To get ‘foo’ from ‘structure’:
@soap['structure']['foo'].value
Return from your method to respond. In our case we should just respond with
return true #or return false
In complex scenarios we can do
return { :foo => 'foo', :bar => 'bar' }