开发者

Sorry but Another WCF service The maximum array length quota (16384) has been exceeded

I know this question has been asked many times on here but I have gone through each of these and can't seem to get it to work for me. From my client, I am trying to pass in 2 byte parameters and return byte[] but while it works fine when the parameters are small, it throws the "WCF service The maximum array length quota (16384) has been exceeded".

Here is my Client web.config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_GenerateDocument" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
   开发者_如何学运维       useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_IGenerateDocument" 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>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:6543/GenerateDocument.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_GenerateDocument"
        contract="NWIS.DocumentGeneratorService.IGenerateDocument" name="NWIS.DocumentGeneratorService.GenerateDocument.svc" />
      <endpoint address="http://localhost:6543/GenerateDocument.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGenerateDocument"
        contract="DocGenService.IGenerateDocument" name="BasicHttpBinding_IGenerateDocument" />
    </client>
  </system.serviceModel>

and here is the Server equivalent:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_GenerateDocument" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10: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="5242880" maxArrayLength="2147483646" 
                        maxBytesPerRead="4096" maxNameTableCharCount="5242880"/>
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />    
    <services>
      <service name="NWIS.DocumentGeneratorService.GenerateDocument" behaviorConfiguration="ServiceBehaviour">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:6543/"/>
          </baseAddresses>
        </host>
        <endpoint address="http://localhost:6543/GenerateDocument.svc" binding="basicHttpBinding" 
                  contract="NWIS.DocumentGeneratorService.IGenerateDocument"  />
      </service>
    </services>
  </system.serviceModel>

If anyone could see the reason that this works for say 400 bytes but does not for say 20000 bytes, I would be grateful for any guidance.

Thanking you all in advance


You have defined your binding configuration on the server side with the extra large values - but you're not using it!

You need to specify in your service endpoint what binding configuration to use!

So change your current config to:

<service name="NWIS.DocumentGeneratorService.GenerateDocument" behaviorConfiguration="ServiceBehaviour">
    ....
    <endpoint 
        address="http://localhost:6543/GenerateDocument.svc" 
        binding="basicHttpBinding" 
        bindingConfiguration="BasicHttpBinding_GenerateDocument"  <== add this line here!!
        contract="NWIS.DocumentGeneratorService.IGenerateDocument"  />
</service>

and then, hopefully, your service will actually use those values you've configured!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜