0

Can't send or receive array with large size in web service (wcf)

I have a method in my Wcf service that returns arraylist. When the count of array is less than 100, it works. But more than 1000, I get this error message:

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.

What's wrong with my web config?

<system.serviceModel>
  <bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBinding" receiveTimeout="00:40:00" 
       sendTimeout="00:40:00" maxBufferSize="2147483647" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
               transferMode="Buffered">
      <readerQuotas maxDepth="2147483647" 
      maxStringContentLength="2147483647" maxArrayLength="2147483647" 
          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
      <security mode="None">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
       </basicHttpBinding>
    </bindings>
    <services>
  <service name="KETABMACazvinService.KETABMACazvinService" 
behaviorConfiguration="KETABMACazvinService.KETABMACazvinServiceBehavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="basicHttpBinding"   
  contract="KETABMACazvinService.IKETABMACazvinService">

      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" 
    contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="KETABMACazvinService.KETABMACazvinServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below 
  to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>

      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

New_Dev
  • 11
  • 4
  • The server may have limits on the size of the downloads or you may be exceeding a timeout. How long does it take for the error message to occur? If the error is happening in 5 seconds then you are probably exceeding the size. If the error is taking around 30 seconds then it indicates you hit a timeout. – jdweng Sep 03 '19 at 09:43
  • @jdweng about 2 seconds – New_Dev Sep 03 '19 at 11:06
  • @jdweng would you please take a look at my webconfig code? – New_Dev Sep 03 '19 at 11:18
  • It is a limit that you cannot control. An admin property on the Machine has a limit. – jdweng Sep 03 '19 at 11:21
  • Why don't you have a `bindingConfiguration` attribute on your service endpoint to indicate you want to use the `MyBasicHttpBindimng` config? See also: https://stackoverflow.com/questions/7491420/bindingconfiguration-vs-bindingname – rene Sep 03 '19 at 12:35
  • @jdweng yes, I correct it acccording to this link answers https://stackoverflow.com/questions/884235/wcf-how-to-increase-message-size-quota – New_Dev Sep 03 '19 at 12:38
  • Which solution worked so other people reading this posting know the solution. The link you provided has a lot of different solutions. Is it the one with the check mark? – jdweng Sep 03 '19 at 12:49

1 Answers1

0

Your idea is good, we are supposed to increase the value of the MaxReceivedMessageSize property. One thing we also should pay attention to is that we should apply the configuration to the actual service endpoint by using bindingConfiguration property of the endpoint section.

Please refer to the below code segments.

<endpoint address="" binding="basicHttpBinding"
  contract="KETABMACazvinService.IKETABMACazvinService" bindingConfiguration="MyBasicHttpBinding">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>

Feel free to let me know if the problem still exists.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22