The maximum message size quota for incoming messages (65536) has been exceeded

狂风中的少年 提交于 2019-11-27 04:39:16

问题


My WCF Service has an OperationContract that accepts, as a parameter, an array of objects. This can potentially be quite large. After looking for fixes for Bad Request: 400, I found the real reason: the maximum message size.

I know this question has been asked before in MANY places. I've tried what everyone says: "Increase the sizes in the client and server config files." I have. It still doesn't work.

My Service's web.config:

<system.serviceModel>
    <services>
      <service name="myService">
        <endpoint name="myEndpoint" address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="myBinding"
                  contract="Meisel.WCF.PDFDocs.IPDFDocsService" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="myBinding"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:15:00"
                 sendTimeout="00:15:00"
                 maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transferMode="Buffered"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

My Client's app.config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPDFDocsService"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:11:00"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 transferMode="Buffered"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None"
                       proxyCredentialType="None"
                       realm="" />
            <message clientCredentialType="UserName"
                     algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8451/PDFDocsService.svc"
                behaviorConfiguration="MoreItemsInObjectGraph"
                binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IPDFDocsService"
                contract="PDFDocsService.IPDFDocsService"
                name="BasicHttpBinding_IPDFDocsService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MoreItemsInObjectGraph">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

What can I possibly be missing or doing wrong? It's as though the service is ignoring what I typed in the maxReceivedBufferSize.

Thanks in advance, Kyle

UPDATE

Here are two other StackOverflow questions where they never received an answer, either:

https://stackoverflow.com/questions/2880623/maxreceivedmessagesize-adjusted-but-still-getting-the-quotaexceedexception-with

WCF MaxReceivedMessageSize property not taking


回答1:


In the service config file, the "name" attribute is missing from the element

<behaviors>
  <serviceBehaviors>
    <behavior name="StackOverflow">

and there should be a reference to this name in the service element:

<system.serviceModel>
    <services>
        <service behaviorConfiguration="StackOverflow" name="myService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding"

In general, it's a good idea to validate, if not always edit, your WCF config files using the "WCF Service Configuration Editor", which is invoked from the Visual Studio "Tools" menu item.

Also there is no endpoint behavior defined for the service. I don't know if this matters.




回答2:


I had the same problem with WCF Test and I had set corectly the config file. If isn't any problems from your config file, I suggest try to test the service with another program eg: SOAP UI, I think this error it's not from the service, it's from the WCF Test.



来源:https://stackoverflow.com/questions/2908857/the-maximum-message-size-quota-for-incoming-messages-65536-has-been-exceeded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!