ActionWebService with Rails 2.0

December 13th, 2007 Quick tipsRails

As of Rails 2.0 ActionWebService has been swapped out for the sexier ActiveResource. This is a great thing for most people as we'd all rather to use AR and HTTP as opposed to AWS and SOAP but sometimes third-party software integrations require SOAP...

The first thing to know is that AWS has been ousted to it's new location.

So if you're going to run a project requiring AWS on Edge Rails:

1) Freeze to Edge Rails

$ rake rails:freeze:edge

2) Freeze ousted AWS to vendor/gems

$ mkdir -p vendor/gems
$ svn export http://svn.rubyonrails.org/rails/ousted/actionwebservice vendor/gems/actionwebservice

3) Load AWS and dependent directories on boot

environment.rb

Rails::Initializer.run do |config|
  config.load_paths += %W( #{RAILS_ROOT}/app/apis )
  config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
    File.directory?(lib = "#{dir}/lib") ? lib : dir
  end
  ...
end

require 'actionwebservice'
...

4) Load lib needed for testing using :invoke

test/test_helper.rb

require 'action_web_service/test_invoke.rb'

Happy SOAPing...

--- --- ---

1 Comment

  1. Comment by brian doll on 12/19/07
    Thanks for this! Initially I had issues getting AWS to work after installing the gem separately (ala the rails 2.x announcement) Then I figured I'd go for a gemsonrails solution and package it up that way. For reasons unknown (or at least, I was too lazy to dig into), that does not work either. Your suggestion (perhaps the simplest!) works perfectly. cheers, b

Commenting is closed for this article.