views:

572

answers:

2

What techniques do people use to "consume" services in the REST stile on .Net ? Plain http client? Related to this: many rest services are now using JSON (its tighter and faster) - so what JSON lib is used?

+2  A: 

I bookmarked this blog post ages ago, although I've never tried it. Sounds like it might help you:

http://blogs.msdn.com/nathana/archive/2007/09/13/wcf-web-programming-or-how-i-learned-to-stop-worrying-and-love-uri-templates.aspx

Matt Hamilton
+5  A: 

My approach was

  1. Write some libraries and interfaces to serialize your objects into REST-compatible XML. You can't neccessarily just use the built-in serializers, because your service may not accept the same kind of XML that .NET wants to give you.

    Example: When passing booleans to a Rails REST service, "true" gets unserialized as true, whereas "True" (which .NET gives you) unserializes to false.

  2. Write some libraries to do the HTTP, wrapping around the basic .NET WebRequest objects. You might get some mileage out of some third party libraries in this area as it tends to be more standard. I found some issues though, such as this lovely bug in the .NET framework, so I'm glad I stuck with the basics.

Orion Edwards
I don't know of any .NET serializer that will produce "True". Which one are you referring to? There are no such problems with the XML Serializer.
John Saunders