Introduction
Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows.
WCF provides a runtime environment for services, enabling you to expose CLR types as services, and to consume other services as CLR types.
Service: the functionality exposed to the world
Client: consuming the functionality from the service.
Main Components
- Endpoint
- Hosting environment
- Service class
The Endpoint in WCF Is ABC
- A- Address (where)
- B-Binding (How)
- C-Contract
WCF supports following transport schemas
- HTTP
- TCP
- Peer network
- IPC (Inter-Process Communication over named pipes)
- MSMQ
Contracts in WCF
- Service Contract
- Service Contract (at class level)
- Operation Contract(at method level)
- Data Contract
- Data contract (at class level)
- Data Member (at property level)
- Fault Contract
- Message Contract
Hosting of WCF
- IIS
- Self Hosting
- WAS (Windows Activation Service)
Implementation
STEPS FOR WCF IMPLEMENTATION
- Console application
- Add reference system.serviceModel.dll
- Include the namespace System.ServiceModel;
Server Side
- Create a service contract
- [ServiceContract (Namespace=http://.......)] (this is for an interface)
- Create an Interface
- Public interface Icalc
- {
- …
- …
- }
- Declare an method of each operation with OperationContract attribute
- [ServiceContract (Namespace=http://.......)]
- Public interface Icalc
- {
- [OperationContract]
- Int add(int n1,int n2);
- [OperationContract]
- Int Sub(int n1,int n2);
- }
- Create an another class which implements the interface
- public class cal_op:ICalc
- {
- public int add(int a,int b)
- {
- return(a+b);
- }
- public int sub(int a,int b)
- {
- return(a-b);
- }
- }

Join the conversation! Your thoughts help the community grow.