WCF 提高传输数据性能方法之一
在WCF中使用Gzip压缩的配置方法
这是一种基于WCF通道传输数据的压缩技术,只要通过配置就可以在自己的项目中使用压缩技术,比较方便!
- 服务端App.config
- <system.serviceModel>
- <services>
- <service behaviorConfiguration="metadataBehavior" name="WcfTest.Services.SwfBuilderService">
- <endpoint address="http://127.0.0.1:99/swfbuild" binding="customBinding" bindingConfiguration="BufferedHttpSampleServer" bindingName="BufferedHttpSampleServer" contract="WcfTest.Contracts.ISwfBuilder" />
- </service>
- </services>
- <extensions>
- <bindingElementExtensions>
- <add name="gzipMessageEncoding" type="GZipEncoder.GZipMessageEncodingElement, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
- </bindingElementExtensions>
- </extensions>
- <bindings>
- <customBinding>
- <binding name="BufferedHttpSampleServer">
- <gzipMessageEncoding innerMessageEncoding="textMessageEncoding" />
- <httpTransport hostNameComparisonMode="StrongWildcard"
- manualAddressing="False"
- maxReceivedMessageSize="65536"
- authenticationScheme="Anonymous"
- bypassProxyOnLocal="False"
- realm=""
- useDefaultWebProxy="True" />
- </binding>
- </customBinding>
- </bindings>
- <system.serviceModel>
- view sourceprint?01 客户端App.config
- <system.serviceModel>
- <bindings>
- <customBinding>
- <binding name="WSHttpBinding_SwfBuilderService">
- <gzipMessageEncoding innerMessageEncoding="textMessageEncoding" />
- <httpTransport manualAddressing="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" proxyAuthenticationScheme="Anonymous" realm="" useDefaultWebProxy="true" />
- </binding>
- </customBinding>
- </bindings>
- </system.serviceModel>
- <extensions>
- <bindingElementExtensions>
- <add name="gzipMessageEncoding" type="GZipEncoder.GZipMessageEncodingElement, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
- </bindingElementExtensions>
- </extensions>
- <client>
- <endpoint address="http://127.0.0.1:99/swfbuild" binding="customBinding" bindingConfiguration="WSHttpBinding_SwfBuilderService" contract="SwfBuild.SwfBuilderService" name="WSHttpBinding_SwfBuilderService">
- </endpoint>
- <metadata>
- <policyImporters>
- <extension type="GZipEncoder.GZipMessageEncodingBindingElementImporter, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
- </policyImporters>
- </metadata>
- </client>
顶(2)
踩(0)
下一篇:asp学习入门经验谈
- 最新评论