Tuesday 31 July 2012

WCF : Binding


1.    What is Binding in WCF?
ü  Simple definition for Binding describes how the client will communicate with service.
ü  Bindings in WCF define the configuration of communication channel between clients and services.
ü  Binding specifies
1. Transport Protocol
2. Message encoding
3. Security Mechanism
4. Reliable Messaging
5. Transactions Support


2.    What are built-in bindings in WCF?
1.      BasicHttpBinding
2.      NetPeerTcpBinding
3.      WSFederationHttpBinding
4.      NetNamedPipeBinding
5.      WSHttpBinding
6.      WSDualHttpBinding
7.      NetTcpBinding
8.      NetMsmqBinding
9.      MsmqIntegrationBinding
I have used BasicHttpBinding, WSHttpBinding and NetTcpBinding mostly.

3.    How can you configure binding in WCF?
You can configure binding either using
a.       Configuration file
b.       Programmatically using code
c.       Both
Specifications given in configuration file are overwritten by code.
I prefer configuring binding in configuration file. It’s easy and efficient.

4.    Explain how bindings are used?
Suppose there is a scenario where a service has to be used by two type of client.
ü  One of the client will access SOAP using http and
ü  Other client will access Binary using TCP.
In such cases we need to configure extra endpoint in configuration file and the job is done.
In the configuration file common behaviors affect all endpoints globally, service behaviors affect only service-related aspects, endpoint behaviors affect only endpoint-related properties, and operation-level behaviors affect particular operations.

In the service behavior below the servieMetadata node is added with attribute httGetEnabled='true'. This attribute will specify the publication of the service metadata. Similarly we can add more behavior to the service.
<system.serviceModel>
    <services>
      <service name="MathService"
        behaviorConfiguration="MathServiceBehavior">
        <endpoint address="" contract="IMathService"
          binding="wsHttpBinding"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MathServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>



5.    Does WCF support custom binding?
Yes, bindings in WCF are completely extensible and we can create a customized one. 

6.    In WCf, which binding is used if you are using WCF-to-WCF communication between processes on the same machine?
NetNamedPipesBinding binding is used.

7.  Which is binding in WCF support message streaming?

ü  Following bindings supports the streaming in WCF: 
1. basicHttpBinding 
2. netTcpBinding 
3. netNamedPipeBinding 
8. Which is binding in WCF support reliable session?
             1.    wsHttpBinding 
             2.     wsDualHttpBinding 
             3.    wsFederationHttpBinding 
             4.    netTcpBinding 

No comments:

Post a Comment