REST-style web service calls have a significant advantage over SOAP based ones in that they do not require tooling support. This makes them particularly easy to call from languages such as Ruby or Python. Unfortunately, the same cannot be said for C#, where the lack of tooling works against the developer.
The reason for this difference is dynamic typing. Languages like Ruby and Python can turn JSON and XML-based results directly into an object model. This can then be accessed using each languages standard method and property syntax. For languages like C#, no such mapping is possible without knowing ahead of time what they object graph is going to look like. This involves a tedious and error-prone process of hand-coding the necessary classes and parsing logic.
With C# 4, all this goes away. By combining it with Nikhil Kothari's Dynamic Rest project, C# and VB developers can get the same clean syntax that the dynamic programmers have come to expect. Since it is based on the early preview, there are some limitations,
Note that in the CTP, there isn't any support for indexers used against dynamic types, which gets in the way of normal array syntax. Hence the workaround above using Item(). However, I've been told, that support for indexing into dynamic types already exists in later builds.
In a follow-up post Nikhil demonstrates using C# 4 to call Amazon and Flickr services.
Community comments
Myth - SOAP needs tooling
by Paul Fremantle /
Re: Myth - SOAP needs tooling
by Jonathan Allen /
Myth - SOAP needs tooling
by Paul Fremantle /
Your message is awaiting moderation. Thank you for participating in the discussion.
It is a complete myth that SOAP requires tooling while REST doesn't. They both require you to read and write some data representation - whether its XML or JSon doesn't really matter. If you have an XML parser or toolkit you can create a SOAP message just as easily as you can do REST. Tooling helps, but tooling can help with REST too.
Paul Fremantle, CTO, WSO2
Re: Myth - SOAP needs tooling
by Jonathan Allen /
Your message is awaiting moderation. Thank you for participating in the discussion.
Honestly though, how often do you people actually trying to hand-roll SOAP messages? Sure it can be done, but the complexity level is so high it just doesn't make sense to do so.