WCF配置文件相關(guān)操作技巧解析
如何運(yùn)用WCF實(shí)現(xiàn)上傳數(shù)據(jù)大小的控制,取決于我們對(duì)WCF配置文件的修改方法。在這里就為大家詳細(xì)介紹一下WCF配置文件的一些修改技巧,以達(dá)到文件大小控制的目的。#t#
默認(rèn)情況下,wcf的服務(wù)端如果發(fā)生異常是不會(huì)將詳細(xì)異常發(fā)送給客戶端的,客戶端只能提到以下籠絡(luò)的提示異常信息:
由于內(nèi)部錯(cuò)誤,服務(wù)器無(wú)法處理該請(qǐng)求。有關(guān)該錯(cuò)誤的詳細(xì)信息,請(qǐng)打開服務(wù)器上的 IncludeExceptionDetailInFaults (從 ServiceBehaviorAttribute 或從 配置行為)以便將異常信息發(fā)送回客戶端,或在打開每個(gè) Microsoft .NET Framework 3.0 SDK 文檔的跟蹤的同時(shí)檢查服務(wù)器跟蹤日志。
于是做了一下修改:
- [ServiceBehavior(AddressFilterMode
AddressFilterMode = AddressFilterMode.
Any, IncludeExceptionDetailInFaults = true)] - public class CommunicationWithUnit :
IContractForUnit - {...}
其中第一個(gè)是去防火墻的,第二個(gè)是客戶端顯示錯(cuò)誤詳細(xì)信息的。
主要還是數(shù)據(jù)大小問(wèn)題,于是又去解決:
在WCF配置文件進(jìn)行修改.
舊的WCF配置文件:
- < 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" maxBuffer
PoolSize="524288" maxReceivedMessageSize="65536"- messageEncoding="Text" textEncoding=
"utf-8" transferMode="Buffered"- useDefaultWebProxy="true">
- < readerQuotas maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"- maxBytesPerRead="4096" maxName
TableCharCount="16384" />- < security mode="None">
- < transport clientCredentialType=
"None" proxyCredentialType="None"- realm="" />
- < message clientCredentialType=
"UserName" algorithmSuite="Default" />- < /security>
- < /binding>
新的WCF配置文件:
- < 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>
以上就是針對(duì)文件上傳大小控制對(duì)WCF配置文件進(jìn)行的修改方法。