默认情况下,wcf的服务端如果发生异常是不会将详细异常发送给客户端的,客户端只能提到以下笼络的提示异常信息:
由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 配置行为)以便将异常信息发送回客户端,或在打开每个 Microsoft .NET Framework 3.0 SDK 文档的跟踪的同时检查服务器跟踪日志。
于是做了一下修改:
[ServiceBehavior(AddressFilterMode AddressFilterMode = AddressFilterMode.
Any, IncludeExceptionDetailInFaults = true)]public class CommunicationWithUnit :
IContractForUnit{...}
其中第一个是去防火墙的,第二个是客户端显示错误详细信息的。
主要还是数据大小问题,于是又去解决:
在WCF配置文件进行修改.
旧的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="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>
新的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>
以上就是针对文件上传大小控制对WCF配置文件进行的修改方法。