What is Windows Communication Foundation? (An introduction of WCF)


WCF  enables you  to build powerful service-oriented systems, based on connected services and applications. The WCF runtime and its  System.ServiceModel  namespace that represents its primary programming interface, is nothing less than the successor and unification of most distributed systems technologies that developers have successfully used to build distributed applications on the Windows platform. Each WCF service has endpoints where client will interact. Each Endpoint consists of ABC!!! Where ABC denotes Address (Where the service is?), Binding (How service will accessed?) and Contract(What Service will do). 

These endpoints actually makes WCF service interesting. One WCF service can contains more than one end points and each endpoint is having different address.  This means that you can have one service, which is flexible and interoperable for any application requirements.

Details on ABC

Address:

It specifies the address of the service. The address depends on various factors, including the transport protocols we are using for the communication.

List of protocols and base address schema

Protocol Base Address Schema
HTTP http
TCP net.tcp
MSMQ net.msmq
PIPE net.pipe

Binding:

It describes how client will connect to service, and the format of the data expected by the service and  responds. A WCF binding is a collection of bindings elements that must include at least one transport protocol binding element, one or more message-encoding protocol binding element, and zero or more other binding elements. Bindings may be defined by selecting individual binding elements, either in code, or in configuration.

List of Bindings and its details

Binding Binding details
BasicHttpBinding It can use the HTTP and HTTPS protocols and encodes messages as XML text. This binding is used to maintain compatibility with client applications previously developed to access .asmx Web services.
WSHttpBinding HTTP communication in conformity with WS-* protocols. It supports the HTTP and HTTPS transport protocols
WSDualHttpBinding Similar to WSHttpBinding, but it is suitable for handling duplex communications. Duplex messaging enables a client and service to perform two-way communication without requiring any form of synchronization (the receiver of a message may transmit any number of responses over a period of time).
WSFederationBinding This binding supports the WS-Federation specifications. WS-Federation defines several models for providing federated security, based on the W-WS-Trust, WS-Security, and WS-SecureConversation specifications. It is based on HTTP communication, in which access to the resources of a service can be controlled based on credentials issued by an explicitly-identified credential provider.
NetTcpBinding Secure, reliable, high-performance communication between Windows Communication Foundation software entities across a network. Binary encoding is used. Supports transactions, reliable session and secure communication. It is typically used in an intranet scenario between computers using the Windows OS.
NetPeerTcpBinding Communication between Windows Communication Foundation software entities via Windows Peer-to-Peer Networking. Supports secure communication and reliable ordered delivery of messages. Binary encoding is used.
NetNamedPipeBinding Secure, reliable, high-performance communication between Windows Communication Foundation software entities on the same machine.
NetMsmqBinding Communication between Windows Communication Foundation software entities via Microsoft Message Queuing (MSMQ). MSMQ is used as the transport to transmit messages between client application and service (both implemented using WCF). This binding enables temporal isolation (messages are stored in a message queue, so the client and the service do not both have to be running at the same time. Binary encoding is used; secure, reliable sessions and transactions are also supported.
MsmqIntegrationBinding For building WCF applications that sends or receives messages from another software entity via MSMQ. For communication with existing applications that use MSMQ message queues.

Contracts:

It describes what operations will be performed by the service

Contracts Contracts details
Service Contracts Service contract describes the list operations that service provides. A Service can have one or more service contracts but there must be atleast one service contract. Each service contract contains
Operation Contracts Each Operation contract describes one operation that will be performed by the service
Data Contracts It is the agreement between the client and service, that describes the data to be exchanged
Message Contracts Message is the packet of data which contains important information. WCF uses these messages to transfer information from Source to destination.
Fault Contracts Service that we develop might get error in come case. This error should be reported to the client in proper manner. At the service end we handle the errors by using try-catch blocks but client should not be interested in how and where the error is, it must be interested in what the error is.

No comments:

Post a Comment