Windows Scripting
  Home arrow Windows Scripting arrow Page 5 - WCF and Proxies
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

WCF and Proxies
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2007-10-18

    Table of Contents:
  • WCF and Proxies
  • Programmatic Client Configuration
  • WCF Architecture
  • The InProcFactory Class
  • Binding and Reliability
  • Requiring Ordered Delivery

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    WCF and Proxies - Binding and Reliability


    (Page 5 of 6 )

    In WCF, reliability is controlled and configured in the binding. A particular binding can support or not support reliable messaging, and if supported, it can be enabled or disabled. Which binding supports which reliability value is driven by the target scenario for that particular binding. Table 1-2 summarizes the relationship between binding, reliability, and ordered delivery and their respective default values.

    Table 1-2. Reliability and binding

    Name Supports reliability Default reliability Supports ordered Default ordered
    BasicHttpBinding No N/A No N/A
    NetTcpBinding Yes Off Yes On
    NetPeerTcpBinding No N/A No N/A
    NetNamedPipeBinding No N/A (On) Yes N/A (On)
    WSHttpBinding Yes Off Yes On
    WSFederationHttpBinding Yes Off Yes On
    WSDualHttpBinding Yes On Yes On

    Table 1-2. Reliability and binding (continued)

    Name

    Supports reliability

    Default reliability

    Supports ordered

    Default ordered

    NetMsmqBinding

    No

    N/A

    No

    N/A

    MsmqIntegrationBinding

    No

    N/A

    No

    N/A

     

     

     

     

     

     

    Reliability is not supported by theBasicHttpBinding,NetPeerTcpBinding, and the two MSMQ bindings,NetMsmqBindingandMsmqIntegrationBinding. The reason is that theBasicHttpBindingis oriented toward the legacy ASMX web services world, which does not have reliability.NetPeerTcpBindingis designed for broadcast scenarios. The MSMQ bindings are for disconnected calls, where no transport session is possible anyway.

    Reliability is always enabled onWSDualHttpBindingto keep the callback channel to the client alive even over HTTP.

    Reliability is disabled by default but can be enabled on theNetTcpBindingand the various WS bindings. Finally, theNetNamedPipeBindingis considered inherently reliable because it always has exactly one hop from the client to the service.

    Ordered Messages

    Message reliability also provides ordered delivery assurance, allowing messages to be executed in the order they were sent, not in the order in which they were delivered. In addition, it guarantees that messages are delivered exactly once.

    WCF lets you enable reliability but not ordered delivery, in which case messages are delivered in the order in which they were received. The default for all bindings that support reliability is that when reliability is enabled, ordered delivery is enabled as well.

    Configuring Reliability

    You can configure reliability (and ordered delivery) both programmatically and administratively. When you enable reliability, you must do so on both the client and the service host sides, otherwise the client will not be able communicate with the service. You can only configure reliability for the bindings that support it. Example 1-23 shows the service-side config file that uses a binding configuration section to enable reliability when using the TCP binding.

    Example 1-23. Enabling reliability with the TCP binding

    <system.serviceModel>
       <services>
          <service name = "MyService">
             <endpoint
                address = "net.tcp://localhost:8000/MyService"
               
    binding  = "netTcpBinding"
               
    bindingConfiguration = "ReliableTCP"
              
    contract = "IMyContract"
             />
          </service>
       </services>
       <bindings>
         
    <netTcpBinding>
             <binding name = "ReliableTCP">
               <reliableSession enabled = "true"/>
             </binding>
          </netTcpBinding>
       </bindings>
    </system.serviceModel>

    When it comes to programmatic configuration, the TCP and the WS bindings offer slightly different properties for configuring reliability. For example, theNetTcpBindingbinding accepts a Boolean construction parameter for enabling reliability:

      public class NetTcpBinding : Binding,...
      {
         public NetTcpBinding(...,bool reliableSessionEnabled);
         //More members
     
    }

    You can only enable reliability at construction time, so when you set reliability programmatically, you need to construct the binding as reliable:

      Binding reliableTcpBinding = new NetTcpBinding(...,true);

    NetTcpBindingalso offers the read-onlyReliableSessionclass, letting you retrieve the reliability status:

      public class ReliableSession
     
    {
         public TimeSpan InactivityTimeout
         {get;set;}
         public bool Ordered
         {get;set;}
         //More members
     
    }
      public class OptionalReliableSession : ReliableSession
      {
        
    public bool Enabled
         {get;set;}
         //More members 
      
    }
      public class NetTcpBinding : Binding,...
      {
        
    public OptionalReliableSession ReliableSession
         {get;}
         //More members
     
    }

    More Windows Scripting Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming WCF Services," published by...
     

    Buy this book now. This article is excerpted from chapter one of Programming WCF Services, written by Juval Lowry (O'Reilly, 2007; ISBN: 0596526997). Check it out today at your favorite bookstore. Buy this book now.

    WINDOWS SCRIPTING ARTICLES

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT