1

我有一个使用控制台应用程序连接到的休息 WCF 服务。控制台应用程序下载文件。小文件工作正常。对于较大的文件,我收到以下错误:

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

这是我在客户端控制台应用程序上的配置文件。

<configuration>     
<system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding maxReceivedMessageSize="2000000"
                  maxBufferSize="2000000">
          <readerQuotas maxStringContentLength="2000000"/>
        </binding>
      </webHttpBinding>
    </bindings>
    </system.serviceModel>
</configuration>

WCF 配置如下:

    <webHttpBinding>
        <binding name="MyTestBinding" maxReceivedMessageSize="10000000" maxBufferPoolSize="10000000" maxBufferSize="10000000" transferMode="Buffered">
            <readerQuotas maxDepth="10000000" maxArrayLength="10000000" maxBytesPerRead="10000000" maxNameTableCharCount="10000000" maxStringContentLength="10000000" />
            <security mode="Transport">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </webHttpBinding>

我正在使用 WebChannelFactory 连接到服务。有什么问题?

4

1 回答 1

3

尝试webHttpBinding在客户端配置文件中分配一个名称,并使用WebChannelFactory Constructor (String, Uri)引用它。这需要一个字符串作为绑定配置名称和服务的 Uri:

<configuration>
  <system.serviceModel>
    <bindings>
      <webHttpBinding name="MyWebHttpBinding">
        <binding maxReceivedMessageSize="2000000"
                 maxBufferSize="2000000">

basicHttpBinding是. http_ protocolMapping_httpBinding

使用name属性集,您可以获得这样的工厂实例:

WebChannelFactory<IContract> factory = new WebChannelFactory<IContract>("MyWebHttpBinding", new Uri("service address"));
于 2013-10-14T23:05:03.623 回答