Windows Communication Foundation (WCF) is a runtime and a set of APIs for creating systems that send messages between services and clients. The same infrastructure and APIs are used to create applications that communicate with other applications on the same computer system or on a system that resides in another company and is accessed over the Internet.
Messaging and Endpoints:
WCF is based on the notion of message-based communication, and anything that can be modeled as a message (for example, an HTTP request or an MSMQ message) can be represented in a uniform way in the programming model. This enables a unified API across different transport mechanisms.
The model distinguishes between clients, which are applications that initiate communication, and services, which are applications that wait for clients to communicate with them and respond to that communication. A single application can act as both a client and a service.
Messages are sent between endpoints. Endpoints are places where messages are sent or received (or both), and they define all the information required for the message exchange. A service exposes one or more application endpoints (as well as zero or more infrastructure endpoints), and the client generates an endpoint that is compatible with one of the service's endpoints.
An endpoint describes in a standard-based way where messages should be sent, how they should be sent, and what the messages should look like. A service can expose this information as metadata that clients can process to generate appropriate WCF clients and communication stacks.
One required element of the communication stack is the transport protocol. Messages can be sent over intranets and the Internet using common transports, such as HTTP and TCP. Other transports are included that support communication with Microsoft Message Queuing (MSMQ) applications and nodes on a Peer Networking mesh. More transport mechanisms can be added using the built-in extension points of WCF.
Another required element in the communication stack is the encoding that specifies how any given message is formatted. WCF provides the following encodings:
- Text encoding, an interoperable encoding.
- Message Transmission Optimization Mechanism (MTOM) encoding, this is an interoperable way for efficiently sending unstructured binary data to and from a service.
- Binary encoding for efficient transfer.
More encoding mechanisms (for example, a compression encoding) can be added using the built-in extension points of WCF.
WCF supports several messaging patterns, including request-reply, one-way, and duplex communication. Different transports support different messaging patterns, and thus affect the types of interactions that they support. The WCF APIs and runtime also help you to send messages securely and reliably.