Monday, June 4, 2012

Binding and Behavior in WCF


Binding says , how the service could be used. Binding specifies
  1. Which protocol to be used
  2. Which encoding to be used.
  3. What type of security requeiremnet to be used like SSL or SOAP message security.
System provided Bindings

basicHttpBinding
  1. This is interoperable binding.
  2. This is commonly used as replacement for earler web service based on ASMX.
  3. It supports HTTP & HTTPS protocols.
  4. It supports MTOM encoding.
  5. It supports text encoding.
wsHttpBinding
  1. This is a secure binding.
  2. This is interoperable binding.
  3. This uses SOAP over HTTP.
  4. This supports reliability over Internet.
  5. This supports transaction over Internet.
  6. This supports security over Internet.
  7. This supports HTTP/HTTPS proptcol
  8. This supports text and MTOM encoding.
  9. This is default binding provided by WCF.
wsDualHttpBinding
  1. This supports all the feature of wsHttpBinding.
  2. This is mainly used for DUPLEX SERVICE CONTRACTS.
  3. This supports bidirectional communication.
webHttpBinding
  1. This is a secure binding.
  2. This is a interoperable binding.
  3. It supports Http/Https protocol.
  4. It does not use SOAP message format.

    image8.gif
wsFederationHttpBinding
  1. This is a secure Binding.
  2. This is interoperable binding.
  3. This supports federated security
  4. This supports Https/Https protocols.
  5. This uses text/MTOM encoding.

    image9.gif
netTCPBinding
  1. This is a secure Binding.
  2. This could only be used if client is also a WCF machine.
  3. This is used to send Binary encoded SOAP message from one WCF computer to another.
  4. This uses TCP (Transimission Control Protocol)
  5. This supports reliability.
  6. This supports transaction,
  7. This supports security.
netNamedPipeBinding
  1. This is a secure Binding.
  2. This could be used over a single WCF computer.
  3. This sends Binary encoded SOAP message over named pipes.
netMSMQBinding
  1. This is a queued Binding.
  2. This uses Binary encoded SOAP message.
  3. This sends message over MSMQ.
  4. Here communication should occur between two computers.
netPeerTCPBinding
  1. This is a secure Binding.
  2. This uses TCP overe peeer to peer.
  3. Communication should occur between two or more computers.
msmqIntegrationBinding
image10.gif

basicHttpContextBinding
This Binding is same as of basicHttpBinding with more attributes , like below
  1. It supports HTTP cookies
  2. It eanble SOAP haeders to excahnge context.
  3. This binding is mainly used for Durable services.
netTCPContextBinding
This Binding is same as of netTCPBinding with more attributes , like below
  1. It eanble SOAP haeders to excahnge context.
  2. This binding is mainly used for Durable services.
wsHttpContextBinding
This Binding is same as of wsHttpBinding with more attributes , like below
  1. It eanble SOAP haeders to excahnge context.
  2. This binding is mainly used for Durable services.
Example :
<system.serviceModel>
 <services>
 <service name="WcfService2.Service1" behaviorConfiguration="WcfService2.Service1Behavior">
                                      <!-- Service Endpoints -->
<endpoint  address="" binding="wsHttpBinding" contract="WcfService2.IService1">
<!-- Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity automatically.-->
 <identity>
      <dns value="localhost"/>
</identity></endpoint>
 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service></services>
 <behaviors>
<serviceBehaviors>
 <behavior name="WcfService2.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<serviceBehaviors>
</behaviors>
</system.serviceModel>

 
Contract of and EndPoint (C)

image12.gif
  1. Contract should be an Interacfe
  2. Contract could be a class also but better approach is interface.
  3. In config file this is preceded by prpject name space name
<endpoint  address="" binding="wsHttpBinding" contract="WcfService2.IService1">


No comments:

Post a Comment