rails 中 soap web service
参考http://adityakircon.blogsome.com/2009/05/07/how-to-install-actionwebservice-in-rails-2/
rails版本 2.2.2
1. gem sources -a http://gems.github.com/
2. gem install datanoise-actionwebservice -v 2.2.2
3. 将下一行加在 config/environtment.rb Rails::Initializer.run do |config| do end 中
config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice', :version => '2.2.2'
4. ruby script/generate web_service hello
5. services\hello_api.rb
class HelloApi < ActionWebService::API::Base
api_method :hello_message, :expects => [{:firstname=>:string}, {:lastname=>:string}], :returns => [:string]
end
6.controller\hello_controller.rb
class HelloController < ApplicationController
wsdl_service_name 'Hello'
#辅助方法
web_service_scaffold :invoke
def hello_message(firstname, lastname)
return "nihao #{firstname}, #{lastname}"
end
end
7. 调用
localhost:3000/hello/wsdl
localhost:3000/hello/invoke