如何获得gzip的COM pression在WCF工作4.5 [英] How to get gzip compression working in WCF 4.5

查看:271
本文介绍了如何获得gzip的COM pression在WCF工作4.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WCF 4.5支持GZIP没有第三方库或手写扩展。 我得到了通过TCP它的工作结合,但不能找到一种方式来获得通过HTTP它的工作结合。 我的WCF - 服务是自托管在一个窗口服务

插件:我不允许使​​用IIS;我不能切换到任何WCF更换。

这个作品用gzip:

 绑定=customBindingbindingConfiguration =tcpCom pressionBindingNAME =TCP
 

这是我目前使用什么HTTP:

 绑定=basicHttpBinding的bindingConfiguration =htt​​pBindingNAME =HTTP
 

该文件并没有真正帮助我: <一href="http://msdn.microsoft.com/en-us/library/dd456789.aspx">http://msdn.microsoft.com/en-us/library/dd456789.aspx.

不过,根据这一点,应该工作:

  

与WCF 4.5的WCF二进制EN codeR期初增加了对COM pression支持。的玉米pression的类型配置与COM pressionFormat属性。客户端和服务必须配置COM pressionFormat属性。 COM pression将适用于HTTP,HTTPS和TCP协议。如果客户端指定要使用的COM pression但服务不支持它的协议异常被抛出指示协议不匹配。欲了解更多信息,请参阅选择一个信息恩codeR

解决方案

根据要求,我复制我的评论,因为答案是:

  

由于此属性仅暴露在   binaryMessageEncodingBindingElement,你需要创建一个自定义   像下面绑定才能使用此功能:

 &LT; customBinding&GT;
  &LT;绑定名称=BinaryCom pressionBinding&GT;
    &LT; binaryMessageEncoding COM pressionFormat =GZip压缩/&GT;
    &LT; httpTransport /&GT;
  &LT; /装订&GT;
&LT; / customBinding&GT;
 

  

和接收COM pressed消息,因此在COM pressionFormat   属性必须在binaryMessageEncoding元件上配置   客户端和服务。 无论是客户端和服务必须同意发送

WCF 4.5 supports GZIP without third party libraries or handwritten extensions. I got it working via TCP Binding, but cannot find a way to get it working via HTTP Binding. my wcf - Service is self hosted in a windows service.

Addon: i am not allowed to use IIS; i can't switch to any WCF replacement.

this works with gzip:

binding="customBinding" bindingConfiguration="tcpCompressionBinding" name="tcp" 

and this is what i currently use for http:

binding="basicHttpBinding" bindingConfiguration="httpBinding" name="http"

The documentation does not really help me: http://msdn.microsoft.com/en-us/library/dd456789.aspx.

But, according to this it should work:

Beginning with WCF 4.5 the WCF binary encoder adds support for compression. The type of compression is configured with the CompressionFormat property. Both the client and the service must configure the CompressionFormat property. Compression will work for HTTP, HTTPS, and TCP protocols. If a client specifies to use compression but the service does not support it a protocol exception is thrown indicating a protocol mismatch. For more information, see Choosing a Message Encoder

解决方案

As per request I copied my comment as answer:

"Since this property is only exposed on the binaryMessageEncodingBindingElement, you will need to create a custom binding like the following to use this feature:

<customBinding>
  <binding name="BinaryCompressionBinding"> 
    <binaryMessageEncoding compressionFormat="GZip"/> 
    <httpTransport /> 
  </binding>
</customBinding> 

and receive compressed messages and therefore the compressionFormat property must be configured on the binaryMessageEncoding element on both client and service. "Both the client and the service need to agree to send

这篇关于如何获得gzip的COM pression在WCF工作4.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆