In this article we will learn about the Basics of Windows Communication Foundation. In this post we are going to discuss the following Building Blocks:
Services: A Service is a collection of operations that are exposed so that the Client can call them and execute them. This is true whether the Service is a WCF service or a Web service. Service Contracts: Service Contracts defines what operations are available and how clients use them. Data Contracts describes the data that the Client and the Service exchange. So the Service Contracts describes not only the Operations supported by the Service but also the message exchange pattern used and the format of the message. Message exchange pattern means whether the client calls the Service and expects a response or the Client calls the method and does not expect a response. The ServiceContract attribute marks an interface as a Service Contract. The OperationContract attribute exposes methods of the interface. Data Contracts: Data Contract describes how the CLR Types are mapped to XSD schema definitions. That enables Complex Types to be serialized and deserialized so they can be passed back and forth. For Example: [DataContract] Public class Customer { [DataMember] Public string CustomerId {get ; set ;} } EndPoints: Host application make the Service available by providing one or more endpoints to Clients. Endpoint consists of:
These are together known as the ABC's of Windows Communication Foundation. Client and Service use the same endpoints to communicate with each other. Bindings: Bindings specify how a service endpoint communicates with the Client Endpoints. A Binding consists of several Binding elements describing some aspect of communication. For Example: How do the messages Transpost? Are they moving over HTTP or do they use TCP protocol for communication? What are the Protocol requirements? Security, reliability, Transactions etc. Message Encoding ( text, binary, etc ) Can be created in the Config file and also dynamically in the Code . WCF Provided Bindings: WCF provides us with various Bindings with each one of them supporting a particulat type of operation. BasicHttpBinding: BasicHttpBinding is compatible with ASMX – Web Services. WSHttpBinding: Conforms to WS-* specifications for reliability, security and transactions . Visual Studio uses this Binding by Default. So if you create a service this would be the Binding the Visual Studio would use. Check out the screenshot below: WS2007HttpBinding: Conforms to OASIS specifications for reliability, transactions and security . WSDualHttpBinding: Supports WS-*plus two way communication. So this is a extension of WSHttpBinding with two way communication. So if you want the Server to call back to the Client you use this Binding. WSFederationBinding: Supports the WS-Federation specification for sharing identities across multiple systems. In the next post we will start out creating a much more enhanced WCF Service. Till then,
Happy Coding.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: