快捷搜索:   服务器  PHP  安全  linux 安全  IIS

WCF 提高传输数据性能方法之一

在WCF中使用Gzip压缩的配置方法 这是一种基于WCF通道传输数据的压缩技术,只要通过配置就可以在自己的项目中使用压缩技术,比较方便!  
  1. 服务端App.config     
  2. <system.serviceModel>     
  3. <services>     
  4.  <service behaviorConfiguration="metadataBehavior" name="WcfTest.Services.SwfBuilderService">     
  5.     <endpoint address="http://127.0.0.1:99/swfbuild" binding="customBinding" bindingConfiguration="BufferedHttpSampleServer" bindingName="BufferedHttpSampleServer" contract="WcfTest.Contracts.ISwfBuilder" />     
  6.    </service>     
  7.  </services>     
  8.  <extensions>     
  9.    <bindingElementExtensions>     
  10.      <add name="gzipMessageEncoding" type="GZipEncoder.GZipMessageEncodingElement, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />     
  11.    </bindingElementExtensions>     
  12.  </extensions>     
  13.  <bindings>     
  14.    <customBinding>     
  15.      <binding name="BufferedHttpSampleServer">     
  16.       <gzipMessageEncoding innerMessageEncoding="textMessageEncoding" />     
  17.        <httpTransport hostNameComparisonMode="StrongWildcard"    
  18.                       manualAddressing="False"    
  19.                       maxReceivedMessageSize="65536"    
  20.                       authenticationScheme="Anonymous"    
  21.                       bypassProxyOnLocal="False"    
  22.                       realm=""    
  23.                      useDefaultWebProxy="True" />     
  24.      </binding>     
  25.    </customBinding>     
  26.  </bindings>     
  27.  <system.serviceModel>    
  28.     
  29.  
   

 

  1. view sourceprint?01 客户端App.config      
  2. <system.serviceModel>
  3.       <bindings>        
  4. <customBinding>          
  5. <binding name="WSHttpBinding_SwfBuilderService">         
  6.  <gzipMessageEncoding innerMessageEncoding="textMessageEncoding" />            
  7. <httpTransport manualAddressing="false"                          authenticationScheme="Anonymous"                          bypassProxyOnLocal="false"                          hostNameComparisonMode="StrongWildcard"                          proxyAuthenticationScheme="Anonymous"                         realm=""                          useDefaultWebProxy="true" />          
  8. </binding>        
  9. </customBinding>      
  10. </bindings>      
  11. </system.serviceModel>      
  12. <extensions>        
  13. <bindingElementExtensions>          
  14. <add name="gzipMessageEncoding" type="GZipEncoder.GZipMessageEncodingElement, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />        
  15. </bindingElementExtensions>      
  16. </extensions>      
  17. <client>          
  18. <endpoint address="http://127.0.0.1:99/swfbuild" binding="customBinding"             bindingConfiguration="WSHttpBinding_SwfBuilderService" contract="SwfBuild.SwfBuilderService"             name="WSHttpBinding_SwfBuilderService">          
  19. </endpoint>        
  20. <metadata>          
  21. <policyImporters>            
  22. <extension type="GZipEncoder.GZipMessageEncodingBindingElementImporter, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />          
  23. </policyImporters>        
  24. </metadata>      
  25. </client>    
 

 

顶(2)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论