Create an active record object, retrieve some stuff from a soap service and then get this:

NoMethodError: You have a nil object when you did’t expect it!
The error occurred while evaluating nil.has_key?
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2172:in `has_attribute?’

If you’re having trouble with active record suddenly throwing exceptions it’s probably because of a namespace collision with your Soap classes defined in the generated file called default.rb, or YourClassName.rb depending upon what arguments you gave to the wsdl2ruby command.

You need to put the data transfer classes into their own module by adding

—module_path MySoap

to the end of the command line. So you have something like this:

wsdl2ruby.rb —wsdl my.wsdl —type client —classdef My —module_path MySoap 

(remember to delete the old files!) 

I last fixed this by hand editing the files and adding in the module definition – so this is by far the easier way.  

Another problem is you get this:

NameError: uninitialized constant SOAP::Mapping::EncodedRegistry 

Just put

gem ‘soap4r’

in the mapping registry file