您的位置:知识库 » .NET技术

WCF分布式开发步步为赢系列的(4):WCF服务可靠性传输配置与编程开发

作者: Frank Xu Lei  来源: 博客园  发布时间: 2009-04-02 10:16  阅读: 5591 次  推荐: 0   原文链接   [收藏]  

  【2】配置方式实现可靠性传输:

  下面我们使用服务端配置文件,启用了TCP绑定的可靠性。代码如下:

  <system.serviceModel>
    
<services>
      
<service behaviorConfiguration="WCFService.WCFServiceBehavior"
        name
="WCFService.WCFService">
        
<endpoint
          address
="http://localhost:8001/WCFService"
          binding
="wsHttpBinding"
          contract
="WCFService.IWCFService">
        
</endpoint>
        
<endpoint
          address
="net.tcp://localhost:8002/WCFService"
          binding
="netTcpBinding"
           bindingConfiguration
="ReliableTCP"
          contract
="WCFService.IWCFService">
        
</endpoint>
        
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
        
<host>
          
<baseAddresses>
            
<add baseAddress="http://localhost:8001/"/>
            
<add baseAddress="net.tcp://localhost:8002/"/>
          
</baseAddresses>
        
</host>
      
</service>
    
</services>
    
<behaviors>
      
<serviceBehaviors>
        
<behavior name="WCFService.WCFServiceBehavior">
          
<serviceMetadata httpGetEnabled="true" />
          
<serviceDebug includeExceptionDetailInFaults="false" />
        
</behavior>
      
</serviceBehaviors>
    
</behaviors>
    
<bindings>
      
<netTcpBinding >
        
<binding name="ReliableTCP">
          
<reliableSession enabled="True"/>
        
</binding>
      
</netTcpBinding>
    
</bindings>
  
</system.serviceModel>

   这里我们要设置服务终结点的绑定配置,bindingConfiguration="ReliableTCP",然后在给出具体绑定配置的可靠传输

Code
<netTcpBinding >
<binding name="ReliableTCP">
<reliableSession enabled="True"/>
</binding>
</netTcpBinding>

  这样WCF服务就会启用可靠消息传递。

 

0
0
 
标签:WCF

.NET技术热门文章

    .NET技术最新文章

      最新新闻

        热门新闻