The Joy of SOAP
I've got a few Rails related jobs lined up over the next few weeks, so there'll probably be an RForward update coming soon as I work on getting the thing deployed on a number of customer sites.
However, I thought I better pass on a bit of ActionWebService (1.1.3) wisdom.
Firstly, when using ActiveRecord::Migrations, mark your date/time columns as of type :date (not :datetime). Otherwise ActionWebService will fail to marshal the actual values out of your model and out into the service (:datetime resolves to a Time object - ActionWebService calls DateTime.parse(value.to_s) which fails - :date resolves to a DateTime object, meaning the call to DateTime.parse works).
Secondly, when writing your SOAP API, if an operation does not take any parameters you must explicitly declare it as such. In Rails 1.0.X you could write api_method do_something, :returns => [[Stuff]] whereas in Rails 1.1.X you have to write
api_method do_something, :expects => [], :returns => [[Stuff]]
1 comment:
Actuall
y the :date advice does not always work. I'm not quite sure what is going on apart from some fields are sometimes being passed through to ActionWebService as :time/:date/:datetime but actually as objects of class Time.
This is fine for :time fields but not for :date or :datetime as Date.parse(t.to_s) and DateTime.parse(t.to_s) both fail when t.is_a? Time
The answer (short-term at least) is a modification to casting.rb ... I will post it later.
Post a Comment