views:

68

answers:

3

I would like to access to multiple web services with a WPF application (Facebook, Twitter, etc...).

I'm not familiar at all with WCF and I was wondering what should I use and why (pros and cons) ? WCF or something else more traditional (like HttpWebRequest) ?

+3  A: 

Why be "traditional" when you can get WCF to do some of the work for you?

If you're accessing a number of services, you'll be writing a lot of duplicate code. You might then refactor the duplication into a framework for calling the services.

WCF already is such a framework, so why write your own?

John Saunders
A: 

I've developed with both WCF and straight web requests.

WCF can be great when developing web services, but there is no guarantee that all third party services will be implementing a protocol that works with WCF (add service reference or svcutil).

Also WCF has the advantage of being hosted anywhere you want, like Console, Web site, WPF application, or Windows Service. When it comes to configuration there is a high learning curve with WCF, so understand that going in.

More and more third party services are adopting a REST interface. This means most of your calls out will be done using the HttpWebRequest. Once you make the call to the service, you will have the issue of deserializing the data coming back (XML, JSON, Key/Value Pair, Fixed Length). If it is XML or JSon, look into using the XmlSerializer or DataContractSerializer.

So if you are writing your own web service (calls coming in), go ahead and use WCF. If you are consuming a web service (calling out to a service i.e. Twitter) you most likely won't have the choice to use WCF.

Khalid Abuhakmeh
Thanks for you answer. But, why won't it be possible to use WCF for services like Twitter ? It seems possible to use WCF in this case.
Ariel32
@Ariel32: WCF does support REST with the WCF REST Starter Kit - and integrating with Twitter is no problem whatsoever. Check out the WCF developer center on MSDN - Aaron Skonnard of Pluralsight did a bunch of screencasts on WCF REST and **specifically** on dealing with Twitter!
marc_s
Wow, I need to check that out. I have worked with WCF before the release of the WCF REST Starter Kit. If you are right then that would be cool.I just don't know how you discover the API of a REST Service unless there is some kind of definition.I'll definitely check it out though, Thanks marc_s.
Khalid Abuhakmeh
I guess you are right, I just found this blog post http://blogs.msdn.com/pedram/archive/2008/04/21/how-to-consume-rest-services-with-wcf.aspxIt shows how to consume the Flikr REST API. It's pretty cool.
Khalid Abuhakmeh
+2  A: 

Go with WCF! It's the way to go, it's the present and future of Microsoft's "connected systems" strategy. You can attach to just about anything using WCF - and contrary to Khalid, I don't think it has a really high learning curve.

Get yourself a good book - I recommend Learning WCF by Michele Leroux Bustamante - check out her samples, play with those.

Also check out online resources:

That should easily get you started! There's a ton more stuff out there.

Watch those two DNR-TV screen casts - they show how to really understand what is needed in terms of WCF configuration. It's really not rocket science! But unfortunately, the "Add Service Reference" and svcutil.exe both have a tendency to create awfully and overly complicated configs - that's not necessary.

More online resources for WCF REST and Twitter:

marc_s