BT

InfoQ Homepage News Dynamic C# in Action

Dynamic C# in Action

Bookmarks

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.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • 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.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.