Developing a WCF Web Service
In contrast to ASP.NET web services which were introduced in .NET v1.0 and built into VS2002 at launch, the Windows Communication Foundation (WCF) was introduced in .NET 3.0, a release not tied to any particular release of Visual Studio. Coming after the launch of VS2005, VS2008 is the first release of Visual Studio with built-in support for WCF: project templates and wizards to match those we just demonstrated for ASP.NET web services. Of course, the files generated and the wizards used aren’t exactly the same, as the goals of WCF are different from those of ASP.NET services. Unlike building web services in ASP.NET, web services built with WCF can be used in non-web contexts. You can share most of the code you write to implement the same service deployed as a .NET Remoting service, or as a local object, and even if you keep it as a web service, you can choose among several web service standards, not just SOAP.
Creating a WCF Service
WCF is designed around the concept of contracts, which are .NET classes and interfaces that describe your service to would-be users. WCF uses interfaces to define a service because they are completely decoupled from any implementation details. In C#, an interface has just the declarations for methods but no implementations, and any class that implements the interface must provide a definition for each method. Since any client to the service will know only about the interface, this ensures that clients do not tie any of their ...