Ebay with Ruby and Ruby on Rails

Currently I am writing a small RoR application which uses eBay. There are at least two different approaches to use the eBay developer api in Ruby:

Sadly both projects are not updated regulary to the latest ebay api version, but they use ebay's wsdl (resp. xsd) description of the web service.

I've first tried Ebay XML Api which works quite well besides a minor flaw with the money class (there is already a bug report and a patch). I have tried to update the library with the build-in rake task to the latest ebay version, but it fails (and I have no idea how to fix it).

So I've moved over to eBay4R which uses soap4R instead of a self made parser like Ebay XML Api to process the wsdl file. Unfortunately the version of soap4R (1.5.5) shipped with Ruby 1.8.6 is not capable to work with the ruby classes which were created by the latest soap4R's wsdl2ruby.
To solve this problems I first installed a new version of soap4R (1.5.7) as a gem:

gem install soap4r --source http://dev.ctor.org/download/

After the installation I've converted the latest eBay scheme (529) via

wget http://developer.ebay.com/webservices/latest/eBaySvc.wsdl
wsdl2ruby --wsdl eBaySvc.wsdl --type client

to ruby classes. Now copy the created files in the lib directory of ebay4R and make some changes to eBayApi.rb:

  • Replace require 'eBayDriver.rb' with
    require 'rubygems'
    gem 'soap4r'
    require 'defaultDriver.rb'
  • Set the correct api version (@ver = 529)
  • Apply this patch

Ebay4R's hello_world example works now with the latest api :).

But using the library with Rails results in an error:

uninitialized constant SOAP::Mapping::EncodedRegistry

This happens because Rails uses the build-in version of soap4R and gem 'soap4r' does not load the newer version then. To tell Rails to use the "gem" version instead I changed my application's environment.rb:

    # Specifies gem version of Rails to use when vendor/rails is not present
    RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION

    # Bootstrap the Rails environment, frameworks, and default configuration
    require File.join(File.dirname(__FILE__), 'boot')
+   require 'rubygems'
+   gem 'soap4r'

After that no further problems occurred and now I successful use ebay4R with the latest ebay api version.

Trackback URL for this post:

http://www.vonloesch.de/trackback/37