tags:

views:

396

answers:

2

I'm looking to understand when to use a WCF services instead of just using webclient or httpwebrequest. I guess I'm also looking to understand the difference between the design patterns that would be appropriate for both.

A: 

I'm currently using WCF for most of the things that I would use WebClient or HttpWebRequest/HttpWebResponse in the past. While there definitely is overhead for learing how to make calls to web methods using WCF, the extensibility of WCF and the abstraction it provides makes it a MUCH better candidate for these types of calls.

I've already used it to make calls to Akismet and RPX pretty easily.

To get started, I'd look at the section of the MSDN documentation titled "WCF Web Programming Object Model", located at:

http://msdn.microsoft.com/en-us/library/bb412204.aspx

casperOne
+1  A: 

Are you talking about when to create a WCF service yourself (over web service), or when to consume an existing web service using WCF instead of .NET 2.0 ASMX clients?

As for creating a WCF service yourself:

  • Gives you a lot more options in terms of hosting (in an app, Windows Service, IIS, WAS)
  • Gives you a lot more security options
  • Gives you a lot more protocol options (besides just HTTP, you can also use WS-*, TCP, Named Pipes, MSMQ and more)
  • Allows you to write your service once, and expose it on multiple end-points with different protocols at the same time

As for using WCF to talk to an existing HTTP (ASMX) web service - I don't see a whole lot of massive benefits, except WCF uses more configuration over code, and it can be good to standardize on one way of doing things, if you already use other WCF services, anyway.

Marc

marc_s