Ruby SOAP – the story continues..

As written before, I've been struggling with Ruby and SOAP. Apart from the fact that I really don't understand why the world likes to use SOAP, I've ran into a couple of issues I'd like to share for future generations:

  • soap4r and ActionWebService don't play nicely. The SOAP implementation that is included in the standard Ruby distribution isn't very nice at all (issues with validating WSDLs), so I tried using soap4r to make SOAP requests to remote services. Single scripts worked eventually, but when including this in a Rails project that also acts as a SOAP server (using AWS), things broke majorly. Not spending too much time, I decided to make SOAP requests from external scripts that I call with exec().
  • soap4r doesn't set the xsi:nil attribute to elements that allow this when the content is nil, but the element is a ComplexType. The solution here was to manually construct the SOAP elements (using SOAP::SOAPElement).
  • On my development machine (OSX with Ruby 1.8.6) things finally worked fine, but when deploying to a production environment (Linux with Ruby 1.8.7), things broke when calling "id" on a SOAP result object with the message "warning: Object#id will be deprecated; use Object#object_id" and instead of the id in the SOAP result, I got the object_id (which is an internal id for the object and utterly useless for my purposes). The solution here was to not call methods on the result object, but treating it as a Hash. So result.id becomes result['id'].

3 Responses to “Ruby SOAP – the story continues..”


  1. 1 Kelly B.

    Thank you for this.
    I am a Ruby newbie and this helped me solve a problem quickly.
    You’re my hero of the day!

  2. 2 wouter

    You’re welcome :)

  3. 3 Alex

    Hi, I generated stubs using soap4r. The web service I want to consume contains complex type parameters. Here’s how it is defined in the wsdl file:

    I’d like to know how you manually constructed the soap elements because I figured this is what I need to do. In my defaultDriver. rb, I have one ‘in’ parameter which is of type ::SOAP::SOAPElement.

    If you could give me some more info it would be greatly appreciated.

    Thanks

Leave a Reply