turboladen / playful

A Ruby implementation of UPnP that works with Ruby >= 1.9.x
MIT License
127 stars 18 forks source link

Apparent use of outdated savon API in service.rb #15

Open sidoh opened 9 years ago

sidoh commented 9 years ago

I'm using the same code I linked in the other issue (https://github.com/turboladen/playful/issues/14).

I may be missing something, but it seems that ~L278 of service.rb is using an outdated savon API. I get this stacktrace:

/home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/playful-0.1.0.alpha.1/lib/playful/control_point/service.rb:286:in `block (2 levels) in define_method_from_action': undefined method `message_tags' for #<Savon::LocalOptions:0x0000000213c598> (NoMethodError)
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/savon-2.0.0/lib/savon/block_interface.rb:10:in `call'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/savon-2.0.0/lib/savon/block_interface.rb:10:in `evaluate'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/savon-2.0.0/lib/savon/operation.rb:41:in `call'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/savon-2.0.0/lib/savon/client.rb:36:in `call'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/playful-0.1.0.alpha.1/lib/playful/control_point/service.rb:285:in `block in define_method_from_action'
    from /home/cmullins/code/me/echo/playground/control_point_test.rb:19:in `block (2 levels) in <top (required)>'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/em/deferrable.rb:151:in `call'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/em/deferrable.rb:151:in `set_deferred_status'
    from /home/cmullins/code/me/echo/playground/control_point_test.rb:46:in `block (3 levels) in <top (required)>'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/em/deferrable.rb:151:in `call'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/em/deferrable.rb:151:in `set_deferred_status'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/playful-0.1.0.alpha.1/lib/playful/control_point/device.rb:176:in `block in fetch'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/em/tick_loop.rb:55:in `call'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/em/tick_loop.rb:55:in `stop'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/em/tick_loop.rb:77:in `block in schedule'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/eventmachine.rb:968:in `call'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/eventmachine.rb:968:in `block in run_deferred_callbacks'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/eventmachine.rb:965:in `times'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/eventmachine.rb:965:in `run_deferred_callbacks'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run_machine'
    from /home/cmullins/.rvm/gems/ruby-2.0.0-rc1/gems/eventmachine-1.0.7/lib/eventmachine.rb:187:in `run'
    from /home/cmullins/code/me/echo/playground/control_point_test.rb:4:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

I tried downgrading the version of savon to no avail. Both 2.7.0 and 2.0.0 appear to have the same issue.

Switching the referenced playful code to use this:

              response = @soap_client.call(action_name.to_s,
                                           {soap_action: "#{st}##{action_name}",
                                            attributes: {'xmlns:u' => st}}) do
                message(params) unless params.nil?
              end

instead of:

            response = @soap_client.call(action_name.to_s) do |locals|
              locals.message_tags 'xmlns:u' => @service_type
              locals.soap_action "#{st}##{action_name}"
              #soap.namespaces["s:encodingStyle"] = "http://schemas.xmlsoap.org/soap/encoding/"

              unless params.nil?
                raise ArgumentError,
                  'Method only accepts Hashes' unless params.is_a? Hash
                soap.body = params.symbolize_keys!
              end
            end

seems to fix the issue.