我知道这两种方法都是自动的,我仍然想禁用它。但是怎么做呢?我试着添加了一个textEncoding="Utf8Encoding"
元素,但是没有什么效果了。
我在我的标准wcf服务中有这个:
<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客户端:
<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’。
<bindings>
<customBinding>
<binding name="test">
<httpTransport decompressionEnabled="false"></httpTransport>
</binding>
</customBinding>
</bindings>
<protocolMapping>
<add binding="customBinding" bindingConfiguration="test" scheme="http" />
</protocolMapping>
发布于 2014-05-08 14:02:38
在客户机和服务器上绑定必须完全相同。设置decompressionEnabled="false"
时发生的关键事情是,它停止将Accept-Encoding
头设置为"gzip,deflate“。很棒的东西。
据我所知,服务甚至不需要有这种配置,因为即使当客户端发送decompressionEnabled="false"
时,它也会使用this内容进行响应。
全工作客户:
<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>
全套服务:
<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>
发布于 2014-05-08 12:40:12
您必须使用customBinding
或通过代码更改DecompressionEnabled性质值来创建DecompressionEnabled性质
https://stackoverflow.com/questions/23541737
复制相似问题