Tuesday, May 28, 2013

Windows Communication Foundation (WCF)



When discuss about web services it is important to deal with client and service.
Service à Functionalities exposed to the world
Client à Party consuming the service
Web Services provide facility to communicate between applications in an efficient way. But we have to face some limitations when work with the web services.
                Communication can happen over Http protocols only
                Only support for the Simplex communication (one way communication ex: radio, TV)
WCF (Windows Communication Foundation) comes with reducing the limitations of the                normal web services and provide more user friendly facilities.
Let’s compare the web services with WCF

Web Services
WCF
Communication can happen over Http protocols only
Can be communicate via Http, TCP, IPC or MSMQ
Only support for simplex communication
Support for simplex, half duplex and full duplex communication
Hosted inside web servers like IIS
Can host in many ways( inside the IIS, windows services and even self-hosting is possible)
Use XmlSerializer
Use DataContractSerializer which is better in Performance as compared to XmlSerializer.
(in XmlSerializer some of the fields can’t serialize ex:-hash tables, classes which not implement the IEnumerable and IDictionary interface, non-public methods and properties)
Unhandled exceptions are returned to the client as SOAP faults
Unhandled exceptions are not returned to clients as SOAP faults.
(A configuration setting is provided to have the unhandled exceptions returned to clients for the purpose of debugging.)
Support for XML and Http binding
Support for different type of binding (WSHttpBinding,BasicHttpBinding,WSDualHttpBinding)


When establishing a service using WCF end point is one of the mostly important thing that we need to know
End point provides the answers to many questions arise during the WCF service. Following are the main points we can identify by using the end point of a WCF service.
Address              describe the location where the service locate from a client perspective
Binding                                describe how can client access to the service (protocol, message format)
Contract              what are the operations can perform using the particular service(functionality provide to the client)


Possible ways of hosting the WCF services

·         Self- Hosting (Console application, Windows applications or any type of manage applications can use to self- hosting)
·         Web servers (IIS)
·         Windows services

Data-Contract serialization Vs. XML serialization
(stay with me for more details soon...................................)

WCF instance modes

Per-Call                –instance create for each call. Most efficient in term of memory but need to maintain the session
Per-Session        –instance create for a complete session of a user so no need to maintain the sessions manually sessions are maintained.
Single                   –only one instance created for all client/user and shared among all and least efficient in terms of memory

Security modes use in WCF
Transport level security

Providing security at the transport layer itself and Concerned about integrity, privacy, and authentication of message.
Guarantees the point-to-point communication and order of packets going through the communication way
But communication problems like dropping network connection can leak the security

Message level security

Secure the message by encrypting it before sending
Guarantees the number of packets delivering and order of packets too


Binding use in WCF
  • BasicHTTP à When converting the already created ASMX web service to WCF service BasicHttpBinding can be used.
  • NetTCP
  • MSMQ



Contract use in WCF
  • ServiceContract
  • OperationContract
  • DataContract
  • DataMember
  • FaultContract
  • MessageContract

(stay with me for more details soon...................................)
References:

No comments:

Post a Comment