[Rails] Webservice External XMLRPC
Háber János
boci at freemind.hu
Wed Jan 4 22:01:46 GMT 2006
Hi!
Interesting. I can't see any error , I tested in my machine and it's
work. Maybe,....if you modify the service try to restart webrick.
Cow
daniel wijnands írta:
> 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"
> ?><methodCall><methodName>Add</methodName><params><param><value><string>dsdfsa</string></value></param><param><value><string>safdasf</string></value></param></params></methodCall>'
> 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
> <?xml version="1.0"
> ?><methodCall><methodName>add</methodName><params><param><value><struct><member><name>html</name><value><string>sadfdsaf</string></value></member><member><name>from</name><value><string>dsafdsaf</string></value></member></struct></value></param></params></methodCall>
>
>
> ActionWebService::Dispatcher::DispatcherError (no such method 'add' on
> API DirectSpoolAPI):
>
> Anybody an idea
More information about the Rails
mailing list