【问题标题】:Updated app.config Still getting WCF Quota Message Size Error更新的 app.config 仍然收到 WCF 配额消息大小错误
【发布时间】:2014-01-10 10:01:43
【问题描述】:

我已将我的 App.config 更新如下:

<system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehaviour">
          <serviceMetadata  httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <!--<service name="NorthWindService" />-->
      <service name="DBConnector.DataRetriever" behaviorConfiguration="DefaultBehaviour">
        <endpoint address="/NorthWind/mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="/NorthWind" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_NorthWind"
          name="NorthWindEndPoint" contract="DBConnector.IDataRetrieve" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/Services/" />
          </baseAddresses>
        </host>
      </service>
    </services>
     <bindings>

    <basicHttpBinding>
      <binding name="BasicHttpBinding_NorthWind" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
        <security mode="None" />
      </binding>
    </basicHttpBinding>
  </bindings>
  </system.serviceModel>

但从 WCFTestClient 调用时仍然出现错误。

传入邮件的最大邮件大小配额 (65536) 已超出。

要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。

我错过了什么?

【问题讨论】:

  • 你的客户端有什么配置?

标签: c# .net wcf binding


【解决方案1】:

你没有为你的客户端显示任何配置,所以我只是把它扔掉了。

您还需要在客户端的 .config 中设置 maxReceivedMessageSize="2147483647" 属性。

沿着这些路线的某个地方(绑定中的一些属性在酿造时被省略:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_NorthWind" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" 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://somesite.com/endpoint.svc"
              binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_NorthWind"
              contract="IYourServiceContract" />
    </client>
</system.serviceModel>

如果不需要,请删除 readerQuotas 元素。

编辑:使用客户端元素更新。

【讨论】:

  • 不确定客户端的配置,你的意思是部分里面的配置吗?
  • 一个客户端有一个端点,在那个端点中你可以指定地址、绑定、绑定配置和合约。上面的示例使用 basicHttpBinding,其名称为 BasicHttpBinding_NorthWind。您在添加服务引用的项目中应该有类似的内容。
  • 与 WCFTEstClient 一起使用时我可以做些什么吗?
  • 当您使用 WCF Test Client 测试应用程序时,会使用默认值自动生成 Client.config。有没有办法编辑它们?
  • 我不确定如何从 wcftest 更改自动生成的配置。当我测试我的服务时,我通常会创建一个控制台项目。这样我就可以检查配置,并根据需要使用模型数据测试每个方法。据我所知,在 wcftest 中,您每次都必须提供数据。
猜你喜欢
  • 2015-04-02
  • 2010-12-15
  • 1970-01-01
  • 1970-01-01
  • 2014-02-01
  • 2017-05-14
  • 2013-11-03
  • 2017-05-05
  • 1970-01-01
相关资源
最近更新 更多