Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why Microsoft's WCF example so complicated?

Tags:

c#

.net

wcf

I'm comparing two examples of WCF. Microsoft's examples http://msdn.microsoft.com/en-us/library/ms734712.aspx uses app.config file, uses generator svcutil.exe to generate client and in general produces much more code.

Another example http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication much simpler - only two C# files, no auto generated code, no app.config.

Both examples seems to do the same thing.

The question is:

  1. should I use app.config in my program or this file is redundant?
  2. should I try to use Microsoft's "auto-generate client" program or it's better to avoid it?
  3. which of these two examples I should follow when implementing own WCF program?
like image 827
Oleg Vazhnev Avatar asked Sep 09 '11 11:09

Oleg Vazhnev


People also ask

What is WCF in .NET with example?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.

What was the first framework to be included with WCF?

WCF Applications came into the picture in . Net 3.0 Framework. This is a framework, which is used for creating Service oriented Applications. You can send the data asynchronously from one end point to another.

Should I use WCF?

WCF is a best fit for scenarios like message queues, duplex communication, end-to-end message security, one way messaging, distributed transactions, etc. WEB API is a best fit to create a resource-oriented services using HTTP/Restful and it works well with MVC-based applications.

Which .NET framework supports WCF?

Starting with . NET Framework 4.5, WCF provides an easier way to configure both self-hosted and web hosted services in code.


1 Answers

WCF allows you to configure the bindings either programmatically or via configuration. Configuration is sometimes convenient if you (or someone else like a test team/customer) trying out different binding options. For example, the QA team could be doing perf testing and trying the different ways to serialize data over the wire. Or, a customer may have different firewall constraints etc...

In both cases, being able to change binding options on the fly without recompiling is useful.

If you know exactly how you want to send the data, then programmatically configuring it and compiling it into your code may be best. It's certainly easier to configure and less error prone.

like image 93
bryanmac Avatar answered Oct 15 '22 07:10

bryanmac