Overview:
The WCF programming model unifies Web Services, .NET Remoting, Distributed Transactions, and Message Queues into a single Service-oriented programming model for distributed computing. It is intended to provide the rapid application development methodology to the development of web services, with a single API for inter-process communication in a local machine, LAN, or over the Internet. WCF runs in a sandbox and provides the enhanced security model all .NET applications provide.
WCF uses SOAP messages for communication between two processes, thereby making WCF-based applications interoperable with any other process that communicates via SOAP messages. When a WCF process communicates with a non–WCF process, XML-based encoding is used for the SOAP messages but when it communicates with another WCF process, the SOAP messages are encoded in an optimized binary format. Both encodings conform to the data structure of the SOAP format, called Infoset.
Service oriented architecture:
WCF is designed in accordance with Service oriented architecture principles to support Distributed computing where services are consumed by consumers. Clients can consume multiple services and services can be consumed by multiple clients. Services typically have a WSDL interface which any WCF client can use to consume the service, irrespective of which platform the service is hosted on. WCF implements many advanced WS* web services standards such as WS-Addressing, WS-ReliableMessaging and WS-Security. While Microsoft is a board member of WS-I it is not clear how many WS-I profiles they are committing to support fully.
WCF Service
A WCF Service is composed of three parts – a Service class that implements the service to be provided, a host environment to host the service, and one or more endpoints to which clients will connect. All communications with the WCF service will happen via the endpoints. The endpoints specify a Contract that defines which methods of the Service class will be accessible via the endpoint; each endpoint may expose a different set of methods. The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted.
WCF provides Windows Activation Services which can be used to host the WCF service. Otherwise the WCF service can also be hosted in IIS or in any process by using the Service Host class, which is provided by WCF. Services can also be self-hosted.
Communication with the service
A client can communicate with a WCF service using any of the RPC-based mechanisms in which the service can be invoked as a method call. Any call to the service will be blocking - that is, it will halt the execution of the client until the service processes the request. The client has to connect to a service using a proxy object, which is connected to the specified endpoint of the service and abstracts the service as an object. All method calls to the proxy object will be routed to the service and the proxy will return the results returned by the service to the caller.
WCF handles creating the local proxy. It retrieves from the endpoint the WSDL definition of the endpoint and creates the proxy that will communicate the data for the service using the protocol specified by the binding of the endpoint. It also has to convert the data returned by the service into a form expected by the caller.
WCF also supports non-blocking calls as well as use of the services by passing messages containing the data to be used by the service. Communicating using messages does not require the use of proxy object. The returned data will also be returned using a message. The caller will be blocked until the call to the service returns. To make use of non-blocking messaging, Message Queues need to be used to handle the delivery and receipt of the messages. Message Queues will also allow an application to work even if the service is temporarily down, with the knowledge that the request will be serviced when the server comes up again.