Pregunta

I know both do the de/compression automatically, I still want to disable it. But how? I tried adding a textEncoding="Utf8Encoding" element, but then nothing worked anymore.

I have this in my standard wcf service:

<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>

This is my wcf client:

  <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>

EDIT: I added this to the service but it isnt working, I keep gettingHTTP/1.1 415 Cannot process the message because the content type 'text/xml;charset=UTF-8' was not the expected type '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>  
¿Fue útil?

Solución

The bindings have to be exactly the same on the client and the server. The key thing that happens when setting decompressionEnabled="false" is that it stops setting the Accept-Encoding header to "gzip,deflate". Great stuff.

As far as I understand, the service wouldnt even need to have this configuration, because it will respond with gzipped content even when configured with decompressionEnabled="false" when a client sends the accept-encoding=gzip.

Full working 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>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <client>
      <endpoint address="http://localhost:5555/Service1.svc"
        binding="customBinding" bindingConfiguration="test"
        contract="IService1"
        name="WebServiceEndpoint" />
    </client>

Full service:

<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>    

Otros consejos

You have to create customBinding with <httpTransport decompressionEnabled="false" /> or thru code change DecompressionEnabled Property value

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top