【发布时间】:2015-08-21 16:58:39
【问题描述】:
我正在 IIS 8 express 上托管的 .NET 4.5 中构建测试 WCF 服务 (PersonService)。我还在 IIS 上安装了动态压缩。据我所知,默认情况下启用 WCF 4.0 向前压缩。为了在服务中启用 httpCompression,我更新了 Web.Config 如下:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.webServer>
<httpCompression>
<dynamicTypes>
<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"/>
</dynamicTypes>
</httpCompression>
<urlCompression doDynamicCompression="true" doStaticCompression="true"/>
</system.webServer>
<system.serviceModel>
<services>
<service name="PersonServiceLibirary.PersonService">
<endpoint address="" binding="basicHttpBinding" contract="PersonServiceLibirary.IPersonService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="524288000" maxBufferSize="524288000" maxReceivedMessageSize="524288000">
</binding>
</basicHttpBinding>
</bindings>
<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>
</system.serviceModel>
</configuration>
问题:我想验证压缩是否真的发生了。如何在发送之前验证响应是否在服务器端被压缩,它也在客户端被解压缩。
注意:我的客户端应用程序也是消耗上述服务的 .NET 控制台应用程序。应用服务和客户端都运行在同一台机器上。
【问题讨论】:
-
1) 使用 telnet 模拟请求并查看您的数据是否可读,或 2) 使用数据包嗅探器并检查您的 TCP 包内容。
-
@norbert van noblemen 我该怎么做?你能给我一些文章或资源吗?我以前没做过
标签: wcf iis-express http-compression