You are on page 1of 5

Windows Communication Foundation (WCF) Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system

for building, configuring and deploying network-distributed services. It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF. It is unified programming model provided in .Net Framework 3.0. WCF is a combined features of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.


WCF is interoperable with other services when compared to . Custom System.where the client and service have to be . Small changes in the configuration will make your requirements. following table provides detailed difference between them.1. Windows service [ServiceContraact] attribute has to be added to the class the method exposed to client Programmin [WebService] attribute has to be g Model added to the class method exposed to client [WebMethod] attribute represents the [OperationContract] attribute represents One-way. WCF offers much more flexibility and portability to develop a service when comparing to web service.Net. 3. In other technology developer has to write the code. TCP.Serialization namespace is used for serialization XML 1.serialization name space System. WCF has integrated logging mechanism.Runtime. Request. MTOM.Net Remoting. MTOM(Message Transmission Optimization Mechanism). Custom XML Encoding Transports Protocols Can be accessed through HTTP. Custom Security Named pipes. windows activation service.Response are the One-Way. Features Hosting Web Service It can be hosted in IIS WCF It can be hosted in IIS. Duplex are Operation different operations supported in web different type of operations supported in service WCF is used for serialization XML 1. Custom Security.0. changing the configuration file settings will provide this functionality.Xml. Reliable messaging. 4. Difference between WCF and Web service Web service is a part of WCF. Transactions .0. Self-hosting. In WCF.P2P. WCF services provide better reliability and security in compared to ASMX web services. Disadvantage Making right design for your requirement is little bit difficult. 2. Can be accessed through HTTP. DIME. Request-Response. MSMQ. Still we are having more advantages over Web service. Binary. there is no need to make much change in code for implementing the security model and changing the binding. TCP.

cs using System. MyWCFServices.Collections. .NET Development Server Create a client application to consume this WCF Service Create a class Library HelloWorldService. namespace HelloWorldService { public class HelloWorldService : IHelloWorldService { public string HelloWorld(string yourname) { return "Hello World : " + yourname. System.Linq.WCF Fundamental • • • • • End Point Bindings and Behavior Contracts and Service host Message and Channel WCF client and Metadata Implementing basic Hello World WCF Service To build a HelloWorld WCF Service by carrying out the following steps: • • • • • Create the solution and project Create the WCF service contract interface Implement the WCF Service Host the WCF Service in the ASP.Text. System.Generic. } } } Create a interface for that class IHelloWorldService.cs using using using using using System. System.

a . We will now add such a file to our web site. HelloWorldService.svc <%@ServiceHost Service="MyWCFServices.web> <system. namespace MyWCFServices { [ServiceContract] interface IHelloWorldService { [OperationContract] string HelloWorld(string yourname).HelloWorldService"%> Modifying the web. System.serviceModel> <behaviors> . Open the web.webServer> <system.Text.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.config file e final step is to modify the web. } } The HelloWorldService is a class library.Generic. if it is hosted on a web server. It has to be hosted in an environment so that client applications may access it Adding an SVC file to the host application Just as an ASMX file is the entry point for a non-WCF Web Service. System.Linq. System.ServiceModel.web> <compilation debug="false" targetFramework="4.0"?> <configuration> <system.0" /> </system.config file of the web site and change it to be like this: <?xml version="1.using using using using System.svc file is the entry point for a WCF Service.Collections.config file of the web site.

Console. Console.HelloWorldService" behaviorConfiguration="MyServiceTypeBehaviors"> <endpoint address="" binding="wsHttpBinding" contract="MyWCFServices.Collections.localhost. using using using using using System.Linq. WcfClient..HelloWorld("haiii")). System. System.WriteLine(s. } } } . System.IHelloWorldService"/> <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/> </service> </services> </system.ReadLine().Generic.serviceModel> </configuration> Starting the host application Create a Console Application and add a Web Reference on that Client Application And Create an object to Service and Call the HelloWorld Method.Text.<serviceBehaviors> <behavior name="MyServiceTypeBehaviors"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service name="MyWCFServices. namespace WcfClient { class Program { static void Main(string[] args) { Service s = new Service().