首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何禁用wcf的gzip?

如何禁用wcf的gzip?
EN

Stack Overflow用户
提问于 2014-05-08 12:25:10
回答 2查看 2.6K关注 0票数 1

我知道这两种方法都是自动的,我仍然想禁用它。但是怎么做呢?我试着添加了一个textEncoding="Utf8Encoding"元素,但是没有什么效果了。

我在我的标准wcf服务中有这个:

代码语言:javascript
运行
复制
<system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />

    <diagnostics>
      <messageLogging logEntireMessage="true"
                                  logMalformedMessages="true"
                                  logMessagesAtServiceLevel="true"
                                  logMessagesAtTransportLevel="true"
                                  maxMessagesToLog="500"/>
    </diagnostics>
  </system.serviceModel>

这是我的wcf客户端:

代码语言:javascript
运行
复制
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <client>
      <endpoint address="http://localhost:5555/Service1.svc"
        binding="basicHttpBinding"
        contract="IService1"
        name="WebServiceEndpoint" />
    </client>
    <diagnostics>
      <messageLogging logEntireMessage="true"
                                  logMalformedMessages="true"
                                  logMessagesAtServiceLevel="true"
                                  logMessagesAtTransportLevel="true"
                                  maxMessagesToLog="500"/>
    </diagnostics>
  </system.serviceModel>

编辑:我将它添加到服务中,但它不起作用,我一直认为gettingHTTP/1.1 415不能处理消息,因为内容类型'text/xml;charset=UTF-8‘不是预期的类型'application/soap+xml;charset=utf-8’。

代码语言:javascript
运行
复制
<bindings>
  <customBinding>
    <binding name="test">
      <httpTransport decompressionEnabled="false"></httpTransport>
    </binding>
  </customBinding>
</bindings>
<protocolMapping>
    <add binding="customBinding" bindingConfiguration="test" scheme="http" />
</protocolMapping>  
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-05-08 14:02:38

在客户机和服务器上绑定必须完全相同。设置decompressionEnabled="false"时发生的关键事情是,它停止将Accept-Encoding头设置为"gzip,deflate“。很棒的东西。

据我所知,服务甚至不需要有这种配置,因为即使当客户端发送decompressionEnabled="false"时,它也会使用this内容进行响应。

全工作客户:

代码语言:javascript
运行
复制
<bindings>
      <customBinding>
        <binding name="test">
          <textMessageEncoding messageVersion="Soap11" writeEncoding="utf-8"></textMessageEncoding>
          <httpTransport decompressionEnabled="false"></httpTransport>
        </binding>
      </customBinding>
    </bindings>
    <protocolMapping>
      <add binding="customBinding" bindingConfiguration="test" scheme="http" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <client>
      <endpoint address="http://localhost:5555/Service1.svc"
        binding="customBinding" bindingConfiguration="test"
        contract="IService1"
        name="WebServiceEndpoint" />
    </client>

全套服务:

代码语言:javascript
运行
复制
<bindings>
      <customBinding>
        <binding name="test">
          <textMessageEncoding messageVersion="Soap11" writeEncoding="utf-8"></textMessageEncoding>
          <httpTransport decompressionEnabled="false"></httpTransport>
        </binding>
      </customBinding>
    </bindings>
    <protocolMapping>
        <add binding="customBinding" bindingConfiguration="test" scheme="http" />
    </protocolMapping>    
票数 3
EN

Stack Overflow用户

发布于 2014-05-08 12:40:12

您必须使用customBinding或通过代码更改DecompressionEnabled性质值来创建DecompressionEnabled性质

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23541737

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档