Hello all,
I''m trying to figure out why ActionWebService (AWS) does not validate
the input types of a xml-rpc call, although the agile book says it
should validate them, its not working for me.
Here is the code I''m using:
class Report < ActionWebService::Struct
member :max_age, :int
end
class Service::Monitor::TransactionsApi < ActionWebService::API::Base
api_method :report,
:expects => [{:data => Report}]
end
class Service::Monitor::TransactionsController < ApplicationController
def report(data)
# NB: Even though we have defined a api with the required
# format (the Report class), RoR ActionWebService still
# accepts invalid data as a hash.
puts ''----------------------------------''
p data
puts ''----------------------------------''
end
end
And this is the test program I''m using (in python):
import xmlrpclib
report_data = {
''max_age'': ''this should raise a XML-RPC
fault''
}
remote =
xmlrpclib.ServerProxy(''http://localhost:3000/service/monitor/transactions/api'')
remote.Report(report_data)
I was expecting to have a XML-RPC fault when running this client, but it
went fine, and the controller got a hash (and not a Report instance), so
do we really have to check all argument types on the controller? with
something like:
raise ''invalid argument'' unless data.class == Report
or I''m missing something here?
What was the rationale for collecting invalid data to a hash instead of
raising an exception?
BTW, I didn''t try SOAP, because the WSDL URL provided by AWS does not
seem to work with a service API that has a ActionWebService::Struct
input argument, is this the intended behaviour?
TIA,
Rui Lopes