2

Is there any way of publishing the parameters expected by the RESTful methods in Ruby on Rails? Using SOAP, we can use WSDL, but does RoR implement WADL or WSDL 2.0 for RESTful services? Edit: I am aware of a SOAP based solution using ActionWebService. I was refering to a RoR equivalent of https://wadl.dev.java.net/

4 Answers 4

4

Yes , Solution for your requirement is installing a Actionwebservice gem in rails , If your using rails 2.3.2 and try installing the Actionwebservice gem using the following command

Step 1 :

 $ gem install datanoise-actionwebservice --source http://gems.github.com

Step 2 : Add the gem to the conf/environment.rb

 config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice'

Step 3 : Generate a webservice

 $ ./script/generate web_service  webservice_name

you could see the generated webservice files in /app/services

Step 4 : Modify your 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

Step 5: Modify your api class in app/services

class WebserviceNameApi < ActionWebService::API::Base
    api_method :add, :expects => [:string, :string], :returns => [:int]

end

Step 6 : You can read the wsdl file

$ ./script/server
$ curl http://localhost:3000/controller/wsdl
2
  • @Srinivaslyer thanks for the detailed answer. However, I am trying to avoid a SOAP based solution. If I use RESTful services, there is no way for a client who does not know about how the service works, to know the parameters the service expects. I wonder if there is any current way of publishing the expected parameters using a WADL in RoR.
    – user135193
    Jul 20, 2009 at 19:44
  • @vdrolia: This is a SOAP-based solution; actionwebservice uses SOAP or xmlrpc.
    – Joe W.
    Oct 23, 2009 at 16:23
1

The answer is "No"; Rails does not provide a way to do this. WSDL 2.0 is arguably used by nobody, let alone by anybody doing REST (even though it's theoretically possible to a certain degree, its support for RESTful HTTP is very limited; e.g. it doesn't support hypermedia). WADL has strong acceptance problems within the REST community, too; with the exception of the Java Jersey framework, I'm not aware of any implementation.

3
  • Even if it were possible to generate WADL, of would use would it be? What would you be able to do that you can't do now? Jan 4, 2010 at 21:02
  • I wanted to see if there was a way of providing the method signature in advance for a RESTful service so that the client can automatically generate a stub based on the the signature. I don't know if this can be done currently.
    – user135193
    Jan 7, 2010 at 7:13
  • 1
    I understand, but given the fact that Ruby doesn't need a defined interface somewhere to call a method, what exactly would that stub buy you? Jan 7, 2010 at 14:48
0

You can generate Ruby clients based on your WADL using REST Describe & Compile. You can find very nice detailed documentation about it in Google Documents.

0

Actually there is one implementation - a gem which can generate WADL from Rails routes: https://github.com/austvik/wadlgen, but it has it's limitations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy