As written in a previous last post, I've been busy with Rails and SOAP. I've been figuring out how to pass hashes to my remote calls instead of an argument list.
The default API requires something like:
api_method :get_my_thingy, :expects => [:id => :int, :name => :string], :returns => [Thingy.struct]
When calling this (e.g. with a ruby soap thingy) it looks something like:
soap.getMyThingy(2, "foo")
But I would like to do:
soap.getMyThingy(:id => 2, :name => "foo")
For this to happen, I introduced an OptionStruct:
module ActionWebService class OptionStruct < ActionWebService::Struct member :id, :int member :name, :string end end
After this, the API should be like:
api_method :get_my_thingy, :expects => [OptionStruct], :returns => [Thingy.struct]
See my previous post for the Thingy.struct
0 Responses to “Rails and SOAP part II”