WCF SOAP服务给出MaxRecievedByte错误

时间:2014-05-02 16:32:47

标签: c# web-services wcf soap

我有一个应用程序,在使用第三方Web服务时最近会抛出很多错误。具体来说,我收到以下错误:

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.

我已经检查了我的web.config中的绑定,它们非常大。当然大于65536(16位无符号短路。)

<binding name="InteractiveOrderHandlerBinding" 
         closeTimeout="00:01:00"
        openTimeout="00:01:00" 
        receiveTimeout="00:10:00" 
        sendTimeout="00:01:00"
        allowCookies="false" 
        bypassProxyOnLocal="false" 
        hostNameComparisonMode="StrongWildcard"
        maxBufferSize="327680" 
        maxBufferPoolSize="524288" 
        maxReceivedMessageSize="327680"
        messageEncoding="Text" 
        textEncoding="utf-8" 
        transferMode="Buffered"
        useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" 
                    maxStringContentLength="81920000" maxArrayLength="16384"
                    maxBytesPerRead="40960000" maxNameTableCharCount="16384" />
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>

过去使用此配置一直运行良好,我们尚未对涉及此代码或此配置的任何代码进行更改。我认为它可能是从服务器反射回来的错误,也许他们从我的代码接收过多的数据而不是相反?但我不想转向他们,直到我做了尽职调查,并确保它不在我身边。

有问题的应用是在Windows 2012上运行的ASP.NET应用程序.IIS7。

这是我配置中的System.ServiceModel。在所有披露中,我的配置都有一个巨大的System.ServiceModel,它实际上在多个文件中。以下是与此服务电话相关的elemetns。

<system.serviceModel>
    <client>
       <endpoint address="https://webxml.choicepoint.com/multistate"
                 binding="basicHttpBinding" 
                 bindingConfiguration="InteractiveOrderHandlerBinding"
                 contract="ChoicePointWS.InteractiveOrderHandler" 
                 name="InteractiveOrderHandlerPort" />

    </clent>

   <bindings>
  <basicHttpBinding>
    <binding name="InteractiveOrderHandlerBinding" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="327680" maxBufferPoolSize="524288" maxReceivedMessageSize="327680"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="81920000" maxArrayLength="16384"
                 maxBytesPerRead="40960000" maxNameTableCharCount="16384" />
        <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
    </binding>
    <binding name="basicHttpBinding" maxReceivedMessageSize="102400000"
        maxBufferSize="102400000" sendTimeout="00:30:00" receiveTimeout="infinite">
        <readerQuotas maxArrayLength="16384000" maxBytesPerRead="40960000"
        maxDepth="32" maxNameTableCharCount="16384000"
        maxStringContentLength="81920000" />
    </binding>
  </basicHttpBinding>

  <wsHttpBinding>
      <binding name="wsHttpBinding" maxReceivedMessageSize="102400000"
               sendTimeout="00:30:00" receiveTimeout="infinite">
          <readerQuotas maxArrayLength="16384000" maxBytesPerRead="40960000"
                        maxDepth="32" maxNameTableCharCount="16384000"
                        maxStringContentLength="81920000" />
      </binding>
  </wsHttpBinding>    
</bindings>  
</system.serviceModel>

TIA。

1 个答案:

答案 0 :(得分:0)

&#34; MaxRecievedByte错误&#34; 是否正确?似乎错误更像是&#34;最大邮件大小..(65536)...已超出&#34;

我怀疑这是你的配置。不是第三方。与您发布的(详细)错误一致,我发现由于 maxReceivedMessageSize 值对于返回的邮件来说太小而导致后来的错误。这个错误似乎是零星的,但根据我的经验,它实际上只是因为有时会收到意外的大响应。考虑使用最大值 2147283954 进行测试(我认为)。

我建议您仔细检查设置并确保更新正确的端点, basicHttpBinding maxReceivedMessageSize