24 Oct

WCF Basics

Share Button

WCF was originally introduced with .Net 3.0 and well defined as unification of the following technologies.

  • NET remoting
  • MSMQ
  • Web services
  • COM+.

Windows Communication foundation – The very basic terminology defines that it is something that is developed and deployed on Windows platform.

A WCF Service is composed of three components:
1. Service Class – A WCF service class implements service which includes a set of methods.
2. Host Environment – A Host environment can be a Console/ Windows Service/ Windows Forms application/ IIS.
3. Endpoints – All communications with the WCF service will happen through the endpoints. The endpoint is composed of 3 parts which are called as ABC’s of endpoint as defines below.
· Address defines where the endpoint is hosted. It’s basically the url. Ex:http://localhost/WCFServiceSample/TestService.svc
· Binding specifies how a client will communicate with the service and the address where the endpoint is hosted.
· Contract defines which methods of the Service class will be accessible via the endpoint; each endpoint may expose a different set of methods.
4. It works with security model – SAML, Kerberos, X509, Username/Password

Different contracts in WCF
1. Service Contract describes the operation that service can provide. Service allows more than one contract. Allows simplex, duplex, request-reply pattern.
2. Data Contract describes the data type which is exposed to the client. This defines the data types, which are passed to and from service.
3. Message Contract – SOAP message format is provided by the WCF runtime for communication between Client and service. If it is not meeting your requirements then we can create our own message format. This can be achieved by using Message Contract attribute.
4. Fault Contract – When the service consumed is not working in the client application, we have Fault Contract to provide documented view for error occurred in the service to client.

Share Button