是否有任何方法可以发布 Ruby on Rails 中 RESTful 方法所需的参数?使用 SOAP,我们可以使用 WSDL,但是 RoR 是否为 RESTful 服务实现 WADL 或 WSDL 2.0? 编辑:我知道使用 ActionWebService 的基于 SOAP 的解决方案。我指的是相当于 https://wadl.dev.java.net/ 的 RoR
最佳答案
是的,满足您要求的解决方案是在rails中安装Actionwebservice gem,如果您使用rails 2.3.2并尝试使用以下命令安装Actionwebservice gem
第 1 步:
$ gem install datanoise-actionwebservice --source http://gems.github.com
第 2 步:将 gem 添加到 conf/environment.rb
config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice'
第 3 步:生成网络服务
$ ./script/generate web_service webservice_name
您可以在/app/services中看到生成的Web服务文件
第 4 步:修改您的 Controller
class YourController < ApplicationController
wsdl_service_name 'webservice_name'
web_service_api webservice_nameApi
web_service_scaffold :invocation if Rails.env == 'development'
def add(name, value)
Your.create(:name => name, :value => value).id
end
end
第 5 步:修改应用/服务中的 api 类
class WebserviceNameApi < ActionWebService::API::Base
api_method :add, :expects => [:string, :string], :returns => [:int]
end
第 6 步:您可以读取 wsdl 文件
$ ./script/server
$ curl http://localhost:3000/controller/wsdl
关于ruby-on-rails - 用于 Ruby on Rails 中的 RESTful 服务的 WADL/WSDL 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1100109/