- WCF replaces all traditional technologies such as .NET Remoting, XML Web Services (including SOAP-based or WSDL services), or MSMQ.
- It offers a single, unified, extendable programming model that encompasses the technologies of the past.
- The only difference of WCF service with a regular class are the attributes on the class itself and on its methods.
- You can host a WCF service by creating a new ASP.NET project and adding the service to it.
- A WCF service consists of both an .svc file and a code-behind file that contains the actual service code.
- The .svc file contains instructions for how to host the service in IIS.
- WCF Terms
Contracts and Descriptions
- The data contract describes every parameter that makes up every message that a service can create or consume.
- The message parameters are defined by XML Schema definition language (XSD) documents, enabling any system that understands XML to process the documents.
- The message contract defines specific message parts using SOAP protocols, and allows finer-grained control over parts of the message, when interoperability demands such precision.
- The service contract specifies the actual method signatures of the service, and is distributed as an interface in one of the supported programming languages.
- Policies and bindings stipulate the conditions required to communicate with a service.
- E.g. the binding must (at a minimum) specify the transport used (for example, HTTP or TCP), and an encoding.
- Policies include security requirements and other conditions that must be met to communicate with a service.
Service Runtime
- The service runtime layer contains the behaviors that occur only during the actual operation of the service, that is, the runtime behaviors of the service.
- Throttling controls how many messages are processed, which can be varied if the demand for the service grows to a preset limit.
- An error behavior specifies what occurs when an internal error occurs on the service, for example, by controlling what information is communicated to the client. (Too much information can give a malicious user an advantage in mounting an attack.)
- Metadata behavior governs how and whether metadata is made available to the outside world. Instance behavior specifies how many instances of the service can be run (for example, a singleton specifies only one instance to process all messages).
- Transaction behavior enables the rollback of transacted operations if a failure occurs.
- Dispatch behavior is the control of how a message is processed by the WCF infrastructure.
- Extensibility enables customization of runtime processes. For example, message inspection is the facility to inspect parts of a message, and parameter filtering enables preset actions to occur based on filters acting on message headers.
Messaging
- 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 a Message Queuing) 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.