REST or WCF?

LachoLacho Horacio TorresUSMember

Hi,

I have a requirement where I have to write an app for iOS,Android and Windows Phone, I have been reading about cross platform architecture and Im not sure about what webservice platform to use, REST Services or WCF services?

How can I decide between REST and WCF? What are the key point to decide between both architectures? I would like to hear pros and cons.

Thanks so much Lacho

Best Answer

Answers

  • KarlHeinzBrehmeArredondoKarlHeinzBrehmeArredondo Karl Heinz Brehme Arredondo BRMember, Beta
    edited November 2012

    We have a framework that came from Windows Mobile, using sync from C#, so all web services are in C# too, IIS. So simply when app was done in iOS, it just connect to it without any rework. Also client C# code from access was copied from Visual Studio 2008 project to MonoTouch (some download DataTable do not generated by MonoDevelop and Silverlight thing)

    It's asmx, not WCF, since netcf 2 do not support it.

    It download (subscribe) to a database with about 50 tables, some with a few records, some with 4k records. For now it's NOT being compressed but download of a database on wifi or 3G is really quick specially on iPad 3, in about 35 seconds to 3˜5 minutes (on bad 3G).

    Download of a "big" 4k table records could take 17 seconds to 1 minute on slow connections and ipad 3.

    Early Windows Mobile downloading and processing files downloaded (and disconnected) used to take 30 minutes (on the C++ time, and low speed connections) in such "big" databases.

  • JonathanPryorJonathanPryor Jonathan Pryor USModerator, Xamarin Team Xamurai

    How can I decide between REST and WCF?

    The dominating factors:

    1. The Mono for Android WCF implementation is incomplete (compared to Silverlight), and at "beta-level" implementation quality.
    2. Do you have an existing WCF-based server?

    If you already have a WCF server (2), then trying Mono's WCF support may be a reasonable idea given (1). If you don't already have a WCF server and don't otherwise need one, go with REST.

  • CHIEWTHOUCHANGCHIEWTHOUCHANG CHIEW THOU CHANG AUMember

    I would prefer go with REST with my defined data structure; It will be more work to do in both server and client. But once you have a well structure and organise data class, as well as class that handle the complex http post request, everything will be simple and easy. For server side, you just create a ashx general http handler class to listen the incoming request will do.

    Regards, Chang

  • LachoLacho Horacio Torres USMember

    Thanks to all for your comments

  • NicWiseNicWise Nic Wise NZMember, Insider ✭✭✭

    Esp after reading @jonp comment, I'd say use RestSharp and do JSON over HTTP (which is what most REST usually ends up being). What you use on the server side doesn't matter - ServiceStack, Rails, ASP.NET WEBAPI thing, ASP.NET MVC, whatever.

    RestSharp is on GitHub.

  • StuartLodgeStuartLodge Stuart Lodge USBeta ✭✭✭
    edited November 2012

    Do you like pain and swearing at configuration files? WCF

    Do you like getting code working? REST

    On the server side, I'd look at using WebApi or ServiceStack as well as the other recommendations above.

  • OldRedthOldRedth Jonathan Dick USInsider ✭✭

    REST. REST. REST, and then rest :)

  • MihaMarkicMihaMarkic Miha Markic SIMember ✭✭✭

    Did anybody actually managed to implement it? I am trying asp.net mvc 3 without much success.

  • JohnWatersJohnWaters John Waters USBeta

    ASP.NET MVC 4 WebAPI is my preference for .NET based REST services, or ServiceStack.

  • JulianWinterJulianWinter Julian Winter GBMember

    Its depends on where your Clients are focused. REST should be nice and simple, buts its low level, and you end up doing a wholeheap of extra work. I spent too lonmg trying to get REST servcies to work with Slverlight Clients that I gave up. The oether downside with REST is that you end up putting a lot of busines layer in your Client code, Bad ! WCF allows you better control and design of Business layer services.

    In a Microsoft only Client environment, I would suggest going with WCF. You get Proxy Client code generaution from the WSDL specifications. So you get Type safe, Object based business layer Interfaces. This makes it much easier to get Robust client side code up and running.

    REST obviosly gives toy reach, but you end up working at such a low resources level, not the business layer.

  • TedTaliaferroTedTaliaferro Ted Taliaferro USMember

    I have worked on projects where you can have a WCF Service accessible via REST by using a WebInvoke attribute above the service Operation Contract (method) and supply a URI in the UriTemplate attribute. It gives you the best of both worlds. Now if the services need to reside in a non-IIS server well score another one for REST.

  • CodeMonkeyCodeMonkey Adrian Estran GBMember ✭✭✭

    @JulianWinter I'm currently evaluating using WCF for my next app, I have used it previously for some non app stuff and thought it was excellent, the flexibility it gives you saves so much time.

    My question to you, what have you discovered about the performance of WCF on mobile devices compared to the likes of rest?

  • YuriShteinmanYuriShteinman Yuri Shteinman CAMember, University
    edited March 12

    Now if the services need to reside in a non-IIS server well score another one for REST
    Not at all. We are hosting our WCF services in stand-alone apps as Windows Services.

    The major pro for WCF is generated proxy which is self documented while for REST you have to provide a good documentation or xsd files so your client can at least generate the classed for your REST.

Sign In or Register to comment.