Hello i have some trouble getting my webservice to run .
I have the following webservice :
class DirectSpoolAPI < ActionWebService::API::Base
api_method :add, :expects => [{:html=>:string},{:from=>:string}],
:returns => [Customer]
end
class DirectSpoolService < ActionWebService::Base
web_service_api DirectSpoolAPI
def add(html,from)
Customer.find(:first)
end
def remove
end
end
class ApiController < ApplicationController
skip_before_filter :login_required
web_service_dispatching_mode :delegated
web_service_scaffold :invoke
web_service(:directspool) {DirectSpoolService.new}
end
The controller behaves fine when accessing it with :
http://localhost:3003/api/invoke, and
curl -d ‘<?xml version="1.0"
?>Adddsdfsasafdasf’
http://localhost:3003/api/directspool
But when i try to access it with the following script :
require “xmlrpc/client”
server = XMLRPC::Client.new(“10.0.0.132”, “/api/directspool”, 3003)
begin
param = server.call(‘add’,:html=>‘sadfdsaf’,:from=>‘dsafdsaf’)
puts “4 + 5 = #{param}”
rescue XMLRPC::FaultException => e
puts “Error:”
puts e.faultCode
puts e.faultString
end
I get the following error : no such method ‘add’ on API DirectSpoolAPI
The rails loggins says :
Processing ApiController#directspool (for 10.0.0.1 at 2006-01-04
22:04:03) [POST]
Parameters: {“methodName”=>“add”, “action”=>“directspool”,
“params”=>{“param”=>{“value”=>{“struct”=>{“member”=>[{“name”=>“html”,
“value”=>{“string”=>“sadfdsaf”}}, {“name”=>“from”,
“value”=>{“string”=>“dsafdsaf”}}]}}}}, “controller”=>“api”}
Web Service Request: add({“html”=>“sadfdsaf”, “from”=>“dsafdsaf”})
Entrypoint: directspool
ActionWebService::Dispatcher::DispatcherError (no such method ‘add’ on
API DirectSpoolAPI):
Anybody an idea ?