2

调用 wcf 服务 (wshttpbinding) 时出现以下错误。我已经将 MaxReceivedMessageSize 设置为最大值(2147483647)。谁能告诉我怎么了?

我正在使用“security mode="Message"”,有问题吗?

错误: 已超出传入邮件 (65536) 的最大邮件大小配额。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性

配置:(客户)

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsDemo" closeTimeout="00:15:00" openTimeout="00:15:00"
          receiveTimeout="00:15:00" sendTimeout="00:15:00" bypassProxyOnLocal="false"
          transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="00:15:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://demo.com/DemoServices/DemoProduct.svc"
        binding="wsHttpBinding" bindingConfiguration="wsDemo" contract="DemoService.IProducts"
        name="wsDemo">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

服务器配置:

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="LargeWS" name="GexaEnrollCustomer.GexaEnroll">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="SecureBinding"
          name="wsDemo" contract="MyInterfaces.IProducts">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" name="wsMex"
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://demo.com/DemoServices/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="LargeWS">
          <serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="200" maxConcurrentSessions="200" />
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="SecureBinding" maxBufferPoolSize="2147483647" closeTimeout="00:15:00" openTimeout="00:15:00"
          receiveTimeout="00:15:00" sendTimeout="00:15:00" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Message">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />

  </system.serviceModel>
4

2 回答 2

5

请注意,错误消息指出“对于传入消息”,这使我相信是服务器端抛出此错误,而不是客户端。MaxReceivedMessageSize除了客户端之外,您可能还需要在服务器上进行设置。

通常,您会将客户端和服务器的配置设置为相同的大小。

于 2011-09-08T16:59:42.310 回答
0

您还需要更改 maxBufferSize。

于 2012-11-15T10:15:45.827 回答