I'm coding a client application connecting to SOAP server similar to Google AdWords?.
Instead of retrieving data each time from the server i decided to marshal it to a file and load at development time.
I created a complex object that contains arrays of nested objects retrieved using soap4r v1.5.8. I got error when loaded marshaled data.
File.open("campaigns", "w+") do |f|
Marshal.dump(@campaigns, f)
end
File.open("campaigns") do |f|
@campaigns = Marshal.load(f) # Error is raised here
end
Error message:
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
RAILS_ROOT: D:/Dima/Work/Edvantis/20070525_DDL/MetaAPI/rails
Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/1.8/soap/mapping/mapping.rb:371:in `safemethodname'
C:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:109:in `__define_attr_accessor'
C:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:92:in `__add_xmlele_value'
C:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:163:in `__import'
C:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:162:in `each'
C:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:162:in `__import'
C:/ruby/lib/ruby/1.8/soap/mapping/registry.rb:100:in `marshal_load'
Marshaled data file is attached.
When i commented a couple of lines in the mapping.rb file error is gone.
def self.safemethodname(name)
#Thread.current[:SOAPMapping][:SafeMethodName][name] ||=
# XSD::CodeGen::GenSupport.safemethodname(name)
name
end
Currently i can't dive deeper in code but i can help with testing or providing additional info.
Thanks,
Dima Samodurov.