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.

Convert your Exchange Calendar to iCalendar with Ruby

This example is one that is already in the README, but I thought I'd post it here anyway.  The reasons for converting an Exchange calendar to ical may be many so I won't surmise why you want to do this.  I for one use it to export out to my Orage calendar.

So without further ado ...

require 'rubygems'
require 'viewpoint'
# Get the instance of Viewpoint. This is a singleton class and will
# have only one instance ever instantiated no matter how many times
# you call #instance
vp = Viewpoint::ExchWebServ.instance
# Set authentication parameters (probably NTLM)
vp.authenticate
# This actually calls EWS's FindFolder SOAP message
vp.find_folders
# Get the instance 'Calendar' and convert it
cal = vp.get_folder("Calendar")
ical = cal.to_ical
puts ical.to_ical
# See: http://github.com/zenchild/Viewpoint/blob/master/lib/viewpoint/calendar.rb#L105 for more
# in depth information about what is going on.
view raw cal2ical.rb hosted with ❤ by GitHub

Tuesday, December 8, 2009

Viewpoint Examples Forthcoming

I recently started writing a library in Ruby that utilizes the Microsoft Exchange Web Service (EWS) to perform some rudimentary tasks.  I was asked by a couple people to provide more examples on how to use the library.  I will be doing so in upcomming blogs.  In the meantime you can look at the library for yourself here:


http://github.com/zenchild/Viewpoint

It is also available via a gem:

gem install viewpoint

There is a bug tracker on Github.  If you have any issues please open a ticket.

Have fun and let me know how you are using it.