@madpilot makes

Creating web services in Ruby on Rails

I’ve been working on setting up web services in Ruby on Rails for 88 Miles and have discovered somethings that may be useful to other users. It may save someone some time, as the documentation for this particular area is a little sparse.

  1. Putting a colon(:) in front of a return type indicates a primative – i.e an integer or string. If you want to return a complex type, leave off the colon

This will return the “Shift” Object. You can return Arrays by using two square brackets:

This will return an array of “Shift” objects.

  1. Raising an exception with only a message invokes a SOAPException (and probably a XML-RPC error too – haven’t tried that yet), which is a much better way of handling errors than returning integers or strings (For those playing at home, check out the “fault” body of the SOAP message)
  1. If you are trying to access the webservices via WDSL, simply add /wsdl at the end of the URL


  1. You can generate the scaffolds for a webservice using the generate script:

# script/generate web_service controller_name