中午测试员在测试系统模块时发现无法通过WCF从服务器下载数据,检查配置文件后,建议开发人员修改站点的WEB.CONFIG文件,具体修改对比如下:

旧的:

<binding name="BasicHttpBinding_ICentaMiddleService" closeTimeout="00:01:00"

openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

useDefaultWebProxy="true">

<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

maxBytesPerRead="4096" maxNameTableCharCount="16384" />

<security mode="None">

<transport clientCredentialType="None" proxyCredentialType="None"

realm="" />

<message clientCredentialType="UserName" algorithmSuite="Default" />

</security>

</binding>

新的:

<binding name="BasicHttpBinding_ICentaMiddleService" closeTimeout="00:01:00"

openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="9223372036854775807"

messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"

useDefaultWebProxy="true">

<readerQuotas maxDepth="6553500" maxStringContentLength="2147483647"

maxArrayLength="6553500" maxBytesPerRead="6553500" maxNameTableCharCount="6553500" />

<security mode="None">

<transport clientCredentialType="None" proxyCredentialType="None"

realm="" />

<message clientCredentialType="UserName" algorithmSuite="Default" />

</security>

</binding>

注意这里修改的主要是maxReceivedMessageSize这个属性,解决了从服务器通过WCF下载大容量数据的问题。

下午测试人员继续测试,发现无法将数据通过WCF保存回服务器端。检查数据后发现,需要被保存的数据超过9K,而WCF服务器端使用的是binding="basicHttpBinding"这个数据绑定方式。思路打开,则应该是由于服务器端的接收的数据大小有限制。

当初次引用服务后,显示的服务器端binding="basicHttpBinding" 的最大上传数据容量是:

<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

maxBytesPerRead="4096" maxNameTableCharCount="16384" />

注意是maxStringContentLength="8192" ,那么判定,是由于绑定的默认值未被修改的缘故。接着修改服务器端的web.config配置文件。修改对比如下:

旧的:

<system.serviceModel>

<behaviors>

<serviceBehaviors>

<behavior name="CVMTransactionCaseServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="AuthTaxTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="DealingTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="HousePassTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PreAuthTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PropertyApplyInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CommonInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CenterAssignServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

<services>

<service name="CentaLine.CVM.Services.CVMTransactionCaseService" behaviorConfiguration="CVMTransactionCaseServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.ICVMTransactionCaseService" />

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>

<service name="CentaLine.CVM.Services.AuthTaxTransactionInfoService" behaviorConfiguration="AuthTaxTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IAuthTaxTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.DealingTransactionInfoService" behaviorConfiguration="DealingTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IDealingTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.HousePassTransactionInfoService" behaviorConfiguration="HousePassTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IHousePassTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.PreAuthTransactionInfoService" behaviorConfiguration="PreAuthTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.PropertyApplyInfoService" behaviorConfiguration="PropertyApplyInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IPropertyApplyInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CommonInfoService" behaviorConfiguration="CommonInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.ICommonInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CenterAssignService" behaviorConfiguration="CenterAssignServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.ICenterAssignService"/>

</service>

</services>

</system.serviceModel>

新的:

<system.serviceModel>

<!--<behaviors />-->

<bindings>

<basicHttpBinding>

<binding name="NewBinding0" maxReceivedMessageSize="6553600">

<readerQuotas maxStringContentLength="6553600" />

</binding>

</basicHttpBinding>

</bindings>

<behaviors>

<serviceBehaviors>

<behavior name="CVMTransactionCaseServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="AuthTaxTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="DealingTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="HousePassTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PreAuthTransactionInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="PropertyApplyInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CommonInfoServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

<behavior name="CenterAssignServiceBehavior">

<serviceMetadata httpGetEnabled="true" />

<serviceDebug includeExceptionDetailInFaults="true" />

</behavior>

</serviceBehaviors>

</behaviors>

<services>

<service name="CentaLine.CVM.Services.CVMTransactionCaseService"behaviorConfiguration="CVMTransactionCaseServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.ICVMTransactionCaseService" />

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

</service>

<service name="CentaLine.CVM.Services.AuthTaxTransactionInfoService"behaviorConfiguration="AuthTaxTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IAuthTaxTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.DealingTransactionInfoService"behaviorConfiguration="DealingTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IDealingTransactionInfoService"/>

</service>

<service name="CentaLine.CVM.Services.HousePassTransactionInfoService"behaviorConfiguration="HousePassTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IHousePassTransactionInfoService"/>

</service>

<!--<service name="CentaLine.CVM.Services.PreAuthTransactionInfoService" behaviorConfiguration="PreAuthTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService"/>

</service>-->

<service name="CentaLine.CVM.Services.PreAuthTransactionInfoService"behaviorConfiguration="PreAuthTransactionInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"

contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService" />

<!--<host>

<baseAddresses>

<add baseAddress="net.tcp://localhost:8080/service" />

</baseAddresses>

</host>-->

</service>

<service name="CentaLine.CVM.Services.PropertyApplyInfoService"behaviorConfiguration="PropertyApplyInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.IPropertyApplyInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CommonInfoService"behaviorConfiguration="CommonInfoServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.ICommonInfoService"/>

</service>

<service name="CentaLine.CVM.Services.CenterAssignService"behaviorConfiguration="CenterAssignServiceBehavior">

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"contract="CentaLine.CVM.Services.ICenterAssignService"/>

</service>

</services>

</system.serviceModel>

主要添加内容:

<bindings>

          <basicHttpBinding>

              <binding name="NewBinding0" maxReceivedMessageSize="6553600">

                  <readerQuotas maxStringContentLength="6553600" />

              </binding>

          </basicHttpBinding>

</bindings>

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0"

contract="CentaLine.CVM.Services.IPreAuthTransactionInfoService" />

最后单元测试,通过!爽!

05-12 03:29