中午測試員在測試系統模塊時發現無法通過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" />
最后單元測試,通過!爽!
