Despite the fact that SOAP-based web services seem to be considered politically incorrect by the Rails community, it is amazingly easy to expose web services from Rails. Ironically enough, it can be a little tricky to consume web services from Rails. Several of my colleagues have asked me to post this. This is mostly due to the strange web services client implementation in Rails (Action Web Services’ client). Essentially, you should just use the native Ruby web services client capability (SOAP::WSDLDriverFactory).Specifically, if you use the guidelines below it should be easier.

  • Don’t try to use the Action Web Services client. It only works with AWS servers.
  • Don’t use WSDL2Ruby.rb. Its buggy and not complete.
  • DO use the native Ruby SOAP services such as in the following code (the example points to a free sample Trivia web service)require ‘soap/wsdlDriver’ triviaEndpoint=”http://mobquiz.com/question/api”; triviaWsdl=wsendpoint+”?wsdl”service=SOAP::WSDLDriverFactory.new(smswsdl).create_rpc_driver question=service.askQuestion(‘Entertainment’) puts question.question