Wednesday, March 28, 2007

soap4r and NetSuite revisited

In the last post I mentioned that the generated file (default.rb) contained redundant object definitions. I also ended with the concern about the RecordRef element not appearing to be correct. That led me to look at the generator and as it turns out I was invoking the wrong one. Funny thing, the soap4r gem ships with wsdl2ruby.rb and places them in two different locations. The first (in OSX) was in /opt/local/bin where the second was in /opt/local/lib/ruby/gems/1.8/gems/soap4r- Yesterday we explictly invoked the one in the gem, disregarding the the executable wrapper in /opt/local/bin. That was the mistake, as the results can be easily reproduced with executing
ruby /opt/local/lib/ruby/gems/1.8/gems/soap4r- --wsdl --type client
The problem being that the wrapper adds the necessary "requires" for referencing the gem's code (correct results) and not the standard (incorrect results).

Using the correct wsdl2ruby the following test works without any modifications to the generated code:

require 'rubygems'
require_gem 'soap4r'
require 'defaultDriver'

driver =
driver.wiredump_dev = STDOUT

passport = = 'test'
passport.password = 'test'
passport.account ="test"

role =
role.xmlattr_internalId = '123123123'

passport.role = role

response = driver.login(

pp "successful login: #{response.sessionResponse.status.xmlattr_isSuccess}"

No comments: