While I have been know to gripe about WebServicesCore, there are however options now when developing service-oriented applications. Introducing, Dumbarton; Dumbarton is basically a ObjC-C# bridge that makes use of the Mono embedded API to allow you to utilize C# code from within your Cocoa application. Personally, I think writing SOAP consumption code in C# using Mono or .NET is far nicer than trying to write something using C/Objective-C via WebServicesCore, so this is my "favorite" option. The word favorite being in quotes as unfortunately Dumbarton is a bit complex to use and bundle for a smaller Cocoa application.

Dumbarton is however an option, so I wrote up a quick example that makes use of a currency exchange rate webservice via xmethods.com and essentially rehashes the proverbial "Currency Converter" sample project with an up to date exchange rate. I've pushed the project to GitHub in case you want to check out the whole project.

the nitty gritty


Mostly because I'm a lazy developer (who isn't?) I used the standard "wsdl" executable that you can find in .NET or Mono to generate the necessary stub class for providing the last intermediary layer between our desktop application. The method that's generated (synchronous) that we'll write our wrapper for is:
public System.Single getRate(string country1, string country2);
which will handle the actual webservice invocations which we'll write a small Dumbarton wrapper for. Interacting with SOAP webservices in .NET/Mono is quite simple however, so it'd be trivial to take an existing set of generated stubs and modify them, or simply write all the code from scratch.

The Dumbarton wrapper provides the neccessary "boot strapping" for a bridged object between Cocoa and Mono and also "acts" as the bridged object for the C# class. For example, our Dumbarton wrapper class is called CurrencyConverter which is a subclass of DBMonoObjectRepresentation, and in the wrapper method we call:
[self invokeMethod:"getRate" withNumArgs:2,str1,str2];
which will invoke the C# method getRate(string,string) and return a MonoObject pointer. The bridged methods will return a MonoObject pointer which you can either unbox with the DB_UNBOX_* macros provided in the DBBoxing.h file, or you can invoke methods on that object like CurrencyConverter does with:
(MonoString *)(DBMonoObjectInvoke(rateObj,"ToString",0,NULL))
in order to return a string, or another MonoObject pointer to use. Overall it's really simple to use once you have all the ducks in a row, such as llinking against the Mono.framework and the Dumbarton.framework properly, and you load them into the DBMonoEnvironment appropriately.

notes on CurrencyConverter


I bundled a Dumbarton.framework build that I had handy inside the Subversion repository, but I have linked this against the Mono 1.2.3-preview that I have installed on my machine, so I recommend you checkuot the latest Dumbarton from Subversion (svn co svn://svn.myrealbox.com/source/trunk/Dumbarton) and install the latest stable version of Mono (1.2.2). If you feel like trying out the preview, you can grab the Mono 1.2.3 preview installer to link your custom Dumbarton build against. Something to note however, is the Installation Path in the Dumbarton Xcode project is set to /Library/Frameworks currently, so if you want to link against it and bundle it inside your application bundle you'll need to update that to @executable_path/../Frameworks and then bundle it in the same fashion you would with Growl or Sparkle. You will also need to setup a copy files or a build script phase to handle your bundling of the DLLs inside the application bundle as well. Distributing an application that uses Mono and Dumbarton is a bit stickier, as you have to pick and choose which libraries to bundle, etc, check out this thread from the mono-osx list.

the springer final thought


Depending on your familiarity with developing with C# in either Mono or .NET, Dumbarton may be a great option for utilize existing .NET code for webservices, write cross-platform webservices code, or just avoid the pains of WebServicesCore; it can also be another frustrating stop on the avenue of SOAPy pains if you misunderstand how Dumbarton or C# works. It's currently on my ever lengthening todo list to start documenting far more of what you can do with Dumbarton, but hopefully the examples distributed with the source, along with CurrencyConverter provide a good starting point for those who feel crazy enough to try it out.

As a side note, I have 8.6444 pound in my wallet right now.