WCF错误实现 [英] WCF error implemenation
本文介绍了WCF错误实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的先生,
这是我的错误,我在使用nettcpbinding实现WCF服务时得到了。
我只是在阅读一个字符串,它在文本文件中,大小约为8MB,我将其转换为再见,然后读取它,所以在字符串中它返回数据,我在调试中看到了这一点,但是当它将这个字符串数据返回给服务时客户端在自托管环境中显示此错误:
已超出传入邮件的最大邮件大小配额(65536)。
Dear Sir,
Here is my error, I am getting when I implemented WCF Services with nettcpbinding.
I am just reading an string which is in text file and the size of it is around 8MB, i converted it into bye and then read that, so in string it is returning the data , I saw this in debugging but when it is returning this string data to service client on self hosted environment it shows this error :
The maximum message size quota for incoming messages (65536) has been exceeded.
<configuration>
<appsettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appsettings>
<system.web>
<compilation debug="true" />
<httpruntime maxrequestlength="89535600" />
</system.web>
<system.webserver>
<security>
<requestfiltering>
<requestlimits maxallowedcontentlength="89535600" />
</requestfiltering>
</security>
</system.webserver>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.servicemodel>
<client>
<endpoint binding="netTcpBinding" bindingconfiguration="TcpSampleBinding">
contract="WcfServiceLibrary1.IService1" name="SampleClientBinding" />
</endpoint></client>
<bindings>
<nettcpbinding>
<binding name="TcpSampleBinding" closetimeout="00:20:00" opentimeout="00:20:00">
receiveTimeout="00:20:00" sendTimeout="00:20:00" transactionFlow="false"
transferMode="Streamed" maxBufferPoolSize="524288" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerquotas maxdepth="64" maxstringcontentlength="10240" maxarraylength="16384">
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport" />
</readerquotas></binding>
</nettcpbinding>
</bindings>
<behaviors>
<servicebehaviors>
<behavior name="SampleTestServiceBehaviour">
<servicedebug includeexceptiondetailinfaults="true" />
<servicemetadata />
</behavior>
</servicebehaviors>
</behaviors>
<services>
<service behaviorconfiguration="SampleTestServiceBehaviour" name="WcfServiceLibrary1.Service1">
<endpoint address="" binding="netTcpBinding">
name="SampleNetTcpBinding" contract="WcfServiceLibrary1.IService1" />
<endpoint address="mex" binding="mexTcpBinding" bindingconfiguration="">
name="NetTcpMaxBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseaddress="net.tcp://localhost:19957/SampleSvc" />
</baseAddresses>
</host>
</endpoint></endpoint></service>
</services>
</system.servicemodel>
</configuration>
推荐答案
如下所示应用绑定并使用BindingConfiguration作为界面
< binding name =Binding Nameclosetimeout =00:01:00opentimeout =00:01:00 receivetimeout =00:10:00sendtimeout =00:01:00>
maxBufferPoolSize =524288maxBufferSize =2565536maxReceivedMessageSize =2565536>
< readerquotas maxdepth =2147483647maxstringcontentlength =2147483647maxarraylength =2516384>
maxBytesPerRead =2147483647maxNameTableCharCount =2147483647/>
< security mode =None>
< transport clientcredentialtype =None>
Apply binding as given below and use BindingConfiguration for the interface
<binding name="Binding Name" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00">
maxBufferPoolSize="524288" maxBufferSize="2565536" maxReceivedMessageSize="2565536">
<readerquotas maxdepth="2147483647" maxstringcontentlength="2147483647" maxarraylength="2516384">
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientcredentialtype="None">
如果您在本地运行或使用应用程序
If you are running it locally or using an application
这篇关于WCF错误实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文