WCF WS抛MaxReceivedMessageSizeExceeded [英] WCF WS throwing MaxReceivedMessageSizeExceeded

查看:113
本文介绍了WCF WS抛MaxReceivedMessageSizeExceeded的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WCF Web服务,正在接受一些自定义的对象和一些发送的字节数组的文档。

I have a WCF web service that is accepting some custom objects and a number of documents sent as byte arrays.

但每次我送一个文件(不是一个特别大的一个)的WS返回一个400错误的请求,并跟踪记录它似乎已经抛出 MaxReceivedMessageSizeExceeded 。 话说

But each time I send a document (not a particularly large one) the WS returns a 400 bad request, and in the trace log it appears to have thrown a MaxReceivedMessageSizeExceeded. saying

System.ServiceModel.ProtocolException:   最大邮件大小配额   传入消息(65536)已   超标。要增加配额,使用   在MaxReceivedMessageSize物业   相应的绑定元素。

System.ServiceModel.ProtocolException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

现在的客户端应用程序有这个在其的app.config

Now the client app has this in its app.config

<wsHttpBinding>
    <binding name="WSHttpBinding_IReferrals" 
        closeTimeout="00:01:00" openTimeout="00:01:00" 
        receiveTimeout="00:10:00" sendTimeout="00:01:00"
        bypassProxyOnLocal="false" transactionFlow="false" 
        hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
        allowCookies="false">
        <readerQuotas maxDepth="32" 
            maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />

和在WCF 的web.config 我有这样的

and in the WCF web.config I have this

<service behaviorConfiguration="WCFReferrals.Service1Behavior"
        name="WCFReferrals.Referrals">
     <endpoint address="" binding="wsHttpBinding" contract="WCFReferrals.IReferrals">
          <identity>
            <dns value="localhost" />
          </identity>
     </endpoint>
     <endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange" />
 </service>
 ....
 <binding name="wsHttpBinding" maxBufferPoolSize="2147483647"
          maxReceivedMessageSize="2147483647">
     <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="4096" 
            maxNameTableCharCount="16384" />
 </binding>

显然我失去了一些东西的,据我可以看到我都设置waaaaay了什么是必要的最大消息限制。

Clearly I am missing something as as far as I can see I have all the max message limits set waaaaay over what is necessary..

任何帮助将愉快地接受

感谢

NAT

推荐答案

首先:在你的服务器端,您确定绑定使用较大的消息大小配置,但您不要 T参考从你的终点。

First of all: on your server side, you define the binding configuration with larger message size, but you don't reference it from your endpoint.

<service behaviorConfiguration="WCFReferrals.Service1Behavior"
         name="WCFReferrals.Referrals">
   <endpoint 
         address="" 
         binding="wsHttpBinding" 
         bindingConfiguration="LargeSizeMessages"  <== you need to reference the binding config (by specifying its name
        contract="WCFReferrals.IReferrals">
    </endpoint>
    .....
  </service>
  ....
  <binding name="LargeSizeMessages"   <== give it a meaningful name
       maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
       <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
           maxArrayLength="2147483647" maxBytesPerRead="4096" 
           maxNameTableCharCount="16384" />
  </binding>

另外:你在做你的客户端是一回事吗?请问您的客户端配置(的app.config 的web.config )还包括大型邮件大小绑定配置?您的引用的,在绑定配置的&LT;客户端&GT; ..&LT;端点&GT; 元素??

Also: are you doing the same thing on your client-side? Does your client-side config (app.config or web.config) also include that large message size binding configuration? Are you referencing that binding configuration in your <client> .. <endpoint> element??

这篇关于WCF WS抛MaxReceivedMessageSizeExceeded的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆