Savon vs. Handsoap: Accessing a WSDL

This documentation is deprecated, please have a look at “savonrb.com”:http://savonrb.com/!

p. Both clients provide an interface to work with a WSDL. While the Handsoap WSDL support is hidden in some helper class, WSDLs are a first class citizen in Savon. The code for printing out the available SOAP actions looks like this:

require "handsoap/parser"
wsdl = Handsoap::Parser::Wsdl.read(@wsdl_uri)
wsdl.bindings.each {|binding| binding.actions.each{|action| p action.name }}
p Savon::Client.new("some_wsdl").wsdl.soap_actions

p. The Handsoap parser class is part of a Rails generator. The generator can be used for creating a Handsoap service class skeleton and tests:

$ script/generate handsoap http://www.thomas-bayer.com/axis2/services/BLZService?wsdl

      exists  app
      exists  app/models
      create  app/models/blz_service.rb
      exists  test
      exists  test/integration
      create  test/integration/blz_service_test.rb
----
Endpoints in WSDL
  You should copy these to the appropriate environment files.
  (Eg. `config/environments/*.rb`)
----
# wsdl: http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
BLZ_SERVICE_ENDPOINT = {
  :uri => 'http://www.thomas-bayer.com:80/axis2/services/BLZService',
  :version => 2
}
----

p. The skeleton provides method stubs for adding request parameters and result parsing:

def get_bank
  soap_action = ''
  response = invoke('tns:getBank', soap_action) do |message|
    raise "TODO"
  end
end

1 thought on “Savon vs. Handsoap: Accessing a WSDL

  1. Pingback: Savon Handsoap Shootout | #nofail

Comments are closed.