labs

WSDL requests with HAML support

More than I like, I’ve run into situations where I had to post to services from ruby using WSDLs via SOAP requests. While there are some gems out there that help with it, writing your own solution is actually pretty straight forward.

In this post I will describe how you can use HAML to template your SOAP envelope for a WSDL request.

Lets say we are starting of with a WSDL request definition for retrieving snow board endorsers as described here. The WSDL request might look something like this:

[gist id=763aabfd83ba45b1ffbf]

HAML makes it easy to write that xml request a little simpler:

[gist id=efd39e0b6d53a9d344d0]

In a simple action we can then take that template, render it and pass it to a request:

[gist id=5e0c3f82897e411df43e]

Rendering HAML this way lets you pass in an object with params that can then be used to dynamically assign values in the template.

You can send this off to your endpoint and hopefully get some WSDL response back that you can then use to continue.