i am having some problems accessing my web service from outside the
“invoke” functions…
i have the following backend_controller.rb (1) with this a
backend_api.rb (2)…
when i hit it with:
http://localhost:3000/backend/invoke
everything is fine…
when i try it in irb using (3) i get:
irb(main):316:0> result=server.call(“GetMailingList”,“ddd”)
RuntimeError: HTTP-Error: 400 Bad Request
any ideas?
thanks in advance!
(1)
class BackendController < ApplicationController
web_service_dispatching_mode :direct
wsdl_service_name ‘Backend’
web_service_api BackendApi
web_service_scaffold :invoke
def get_mailing_list(api_key)
key = SiteInfo.find(:first).api_key
unless api_key == key
return “Accesss Denied…”
end
list = Array.new
emails = EmailList.find(:all)
emails.each do |e|
unless e.email_address.blank?
list << e.email_address+“\n”
end
end
list.sort!
end
end
(2)
class BackendApi < ActionWebService::API::Base
api_method :get_mailing_list,
:expects => [:string],
:returns => [[:string]]
api_method :get_forward_optins
end
(3)
require ‘xmlrpc/client’
server = XMLRPC::Client.new(“http://localhost:3000/backend/api”)
result = server.call(“GetMailingList”,“ddd”)