MaxReceivedMessageSize的WCF配置出错

时间:2012-10-26 11:13:02

标签: wcf c#-4.0

调用我的服务时出现以下错误;

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.

服务的配置是;

   <bindings>
      <basicHttpBinding>
        <binding name="basic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
          <readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="Company.Product.Service.FileManager.IFileManager">
        <endpoint binding="basicHttpBinding" bindingConfiguration="basic" name="FileManager" bindingNamespace="Company.Product.FileManager.FileManagerService" contract="Company.Product.Service.FileManager.IFileManager" />
        <host>
          <baseAddresses>
            <add baseAddress="http://filemanager.dev.v7.services.Company.net" />
          </baseAddresses>
        </host>
      </service>
    </services>

正如您所看到的,我已相应调整了设置,因此不确定为什么我仍然会收到此错误。

客户端配置;

 <bindings>
      <basicHttpBinding>
        <binding name="basic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>

      <endpoint address="http://filemanager.dev.v7.services.Company.net/service.svc" binding="basicHttpBinding" bindingConfiguration="basic" contract="Company.Product.Service.FileManager.IFileManager" name="FileManager"/>
    </client>

更新

将服务配置更改为此(删除了绑定名称),这现在可以正常工作,但为什么它不适用于命名配置;

<bindings>
      <basicHttpBinding>
        <binding name="" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
          <readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
    </bindings>

1 个答案:

答案 0 :(得分:1)

您还必须更改客户端的app.config。

编辑:

如果将name属性保留为空,则它将应用于未命名的类型的每个绑定。如果配置中有命名绑定,则只有在该名称明确引用时才会被选中。