Windows Communication Foundation (WCF) is Microsoft's framework for building distributed applications and services. It allows developers to build secure, reliable, transacted solutions that integrate across platforms. WCF supports web services, .NET remoting, and MSMQ-style messaging. It can host services in IIS, WAS, or as Windows services. WCF uses bindings to specify transport and protocol details and contracts to define service functionality. Services can expose operations using request-reply, one-way, or callback patterns. WCF also supports REST-style services over HTTP.
2. Introduction
WCF is a programming paradigm for building network distributed services.
Is the latest framework for building SOA applications.
Is a combined features of web services, .NET remoting, MSMQ, COM+.
3. WCF vs. Web services
Web Service
WCF service
Can be hosted in IIS
Can be hosted in IIS , WAS, Windows service
One way, request-response operation types
One way , request-response , duplex
System.Xml.Serialization is used for serialization
System.Runtime.Serialization is used for
serialization
Can be accessed through HTTP
HTTP ,TCP , MSMQ , P2P
Security
Security, Reliable messaging, Transactions
5. Bindings
Bindings are used to specify the transport, encoding, and protocol details required for clients and services to communicate with each other.
Binding Types
1.
BasicHttpBinding
2.
WSHttpBinding
3.
WSDualHttpBinding
4.
WSFederationHttpBinding
5.
NetTcpBinding
6.
NetNamedPipeBinding
7.
NetMsmqBinding
8.
NetPeerTcpBinding
6. Contracts
The contract is a standard way for describing what the service does.
There four types of the contracts
1. Service Contract
2. Data Contract
3. Message Contract
4. Fault Contract
7. Hosting
The advantage of WCF over web services is that WCF services can be hosted in IIS, Self Hosting, Windows activation
service.
8. Throttling
WCF throttling provides some properties that you can use to limit how many instances or sessions are created at the
application level.
Attribute
Description
maxConcurrentCalls
Limits the total number of calls that can currently be in progress
across all service instances. The default is 16.
maxConcurrentInstances
The number of InstanceContext objects that execute at one time
across a ServiceHost. The default is Int32.MaxValue.
maxConcurrentSessions
A positive integer that limits the number of sessions a ServiceHost
object can accept. The default is 10.
9. Operations
In WCF there are three ways for communication
1. One way
2. Request-Reply(Default)
3. Call back
Request-Reply
One-Way
10. Events
Events allow the client or clients to be notified about something that has occurred on the service side. An event may result
from a direct client call, or it may be the result of something the service monitors. The service firing the event is called the
publisher, and the client receiving the event is called the subscriber.
11. WCF Rest services
REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a stateless, client-server,
cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used.
REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms
such as CORBA, RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines.
In many ways, the World Wide Web itself, based on HTTP, can be viewed as a REST-based architecture.
RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete
data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.
REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.).
Later, we will see how much more simple REST is.