Recently, I blogged about how to connect to Salesforce and use the SOAP API using WCF. Recently, my colleague Mike Welburn told me about the Salesforce Toolkit for .NET, which looked very intriguing. The toolkit is a set of code built on the Portable Class Library that uses the Rest API to communicate with Salesforce. I decided I would write a quick demo app to give it a spin and see if this is something we could use here at Sonoma Partners to assist in building integration, migration or mobile applications.
To start, the documentation for the application is located here. From that documentation, I was able to build the following (very) simple console application that proved out the basics of what the library can do and how easy it is to use it:
The code here is pretty straightforward, so I won’t go through it line by line. There are, however, a few things worth noting here. First is the use of two sets of credentials from the Windows vault – the vault only lets you store usernames and passwords so there wasn’t a nice way to store the consumer key and secret with the username and password. Second, this library is built upon .NET 4.5’s async/await paradigm, so you need to Wait() on the task to finish to prevent the process from terminating early (in a console application). Lastly, this toolkit does allow the use of anonymous types when communicating with Salesforce (see the update example). This is a nice feature which has the potential to cut down on the number of classes and files you need to write in your applications.
So now for the real question: Does this toolkit provide us enough benefit to justify adding it as an external dependency?
One of the things we always have to be cognizant of when building applications, especially integrations, is that the code we build has the potential to be around for a very long time. Any external dependencies we introduce to the application have to either:
- Come from a known name so that we can be reasonably sure it will continue to be supported
- Add enough value to make the risk of it stagnating worthwhile
In this toolkit’s case, it meets both criteria, especially if we look to the future. This toolkit is available on the Developerforce Github account, which indicates it is officially supported by Salesforce and will continue to be maintained going forward. It also provides us with code to handle what I would consider to be the most painful part of any application: authentication. This alone makes the toolkit a worthwhile addition to any application that needs to connect with Salesforce. This is a library I look forward to seeing grow in the coming months, and will definitely recommend whenever we have a project with requirements that this toolkit can help solve.
One Further Sample
Mike Welburn also alerted me to this excellent post which gives a more in depth sample on how to set up an application to use this library, including screen shots of what you need to do in Salesforce. Definitely give it a look over if you’re having issues getting going.