You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 8, 2024. It is now read-only.
troelskn edited this page Sep 13, 2010
·
3 revisions
From 1.1.0, Handsoap supports asynchronous calls. To take proper advantage of this, you should use the EventmachineHTTP driver. Services that use the async interface looks slightly different than the regular blocking ones. A service with an async action might look like this:
class MyService < Handsoap::Service
def get_foos(name, &block)
async(block) do |dispatcher|
dispatcher.request("x:GetFoos") do |m|
m.add "name", name
end
dispatcher.response do |response|
(response/"//ns:GetFoosResponse/foo").map {|foo| parse_foo(foo) }
end
end
end
def parse_foo(node)
{ :id = node[:foo_id], :name => node[:name] }
end
end
Instead of returning a result right away, the method get_foos yields a Deferred. The code that uses this service would thus look like this:
MyService.get_foos("lorem ipsum") do |d|
d.callback do |foos|
puts "Got #{foos.size} foo's back"
end
d.errback do |error|
puts "Oh noes!"
end
end