Thursday, December 10, 2009

Converting from Soap4r to Handsoap

A neat little project was mentioned to me the other day in a conversation on GitHub with user JRun. It's called Handsoap and it has some very interesting features that look to make programming SOAP clients a bit easier.  I've had a couple days to look at it and decided to try and port some code to it.  My first impressions have been fairly positive.  It gives you tremendous power on how you handle your SOAP requests and responses, but I find it just as cumbersome as Soap4r in it's handling of complex types.  I think Soap4r might gain out in this category just by the shear amount of code that gets generated for you.  That said, Handsoap is fast, simple and I will probably use it in future projects that require SOAP.

One thing I did find much easier to deal with is SOAP headers.  In Soap4r I had to create an entire class just to add an element to the SOAP header.  This was required for my Viewpoint project to add the RequestServerVersion element to the header.  With Handsoap all I had to do was add the following to the 'on_create_document' hook:


header = doc.find('Header')
header.add('t:RequestServerVersion') {|rsv|
rsv.set_attr('Version','Exchange2007_SP1')
}


If you have programmed with Soap4r before I would encourage you to give Handsoap a try.

No comments:

Post a Comment