尝试了一切以在 WCF 服务上启用压缩,但服务在 basicHttpBinding 上仍然没有成功,因此它将内容类型返回为text/xml;字符集=utf-8。在我的 applicationHost.config 添加大量动态类型:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" doDiskSpaceLimiting="false" maxDiskSpaceUsage="100000" minFileSizeForComp="0" noCompressionForHttp10="false" noCompressionForProxies="false" noCompressionForRange="false" dynamicCompressionBufferLimit="6553600">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
<add mimeType="text/*" enabled="true" />
</staticTypes>
<dynamicTypes>
<add mimeType="application/json" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/atom+xml;charset=utf-8" enabled="true" />
<add mimeType="application/soap+xml" enabled="true" />
<add mimeType="application/soap+xml; charset=utf-8" enabled="true" />
<add mimeType="application/soap+xml; charset=ISO-8895-1" enabled="true" />
<add mimeType="application/msbin1" enabled="true" />
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="Application/octet-stream" enabled="true" />
<add mimeType="text/xml; charset=utf-8" enabled="true" />
<add mimeType="application/xml; charset=utf-8" enabled="true" />
<add mimeType="application/soap+msbin1" enabled="true" />
<add mimeType="*/*" enabled="true" />
</dynamicTypes>
</httpCompression>
在提琴手上: 请求:
POST http://[omitted]/Service/ HTTP/1.1
Content-Type: text/xml; charset=utf-8
VsDebuggerCausalityData: uIDPo01MZ7JWHO9Kg43Hd3AGkiQAAAAASwm/c9G/206hW6j58tpV5waE+e97MShJvqGukMzMybEACQAA
SOAPAction: "http://tempuri.org/IService/GetCountries"
Host: [omitted]
Content-Length: 137
Expect: 100-continue
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
回复:
HTTP/1.1 200 OK
Via: 1.1 PROXY
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Content-Length: 81623
Date: Tue, 20 Nov 2012 18:20:48 GMT
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
我还能做什么?