另一个WCF MaxMessageSize错误

时间:2011-07-20 13:51:44

标签: .net wcf

所以我遇到了经常使用我正在处理的WCF服务的“超出最大邮件大小”错误。奇怪的是,将其他帖子建议的所有邮件大小设置设置为似乎没有做任何事情;我仍然得到同样的错误。

这是我的服务器配置。客户端不是.net,因此没有客户端配置。

有什么想法吗?

 <services>
        <service name="MyService" behaviorConfiguration="HTTPMetadataBehavior">
            <endpoint address="http://localhost:2624" binding="webHttpBinding"
              bindingConfiguration="WebHttpSettings" contract="IMyService" />
            <endpoint address="mex"
            binding="mexHttpBinding"
            contract="IMetadataExchange" />
        </service>
    </services>
 <behaviors>
      <serviceBehaviors>
        <behavior name="HTTPMetadataBehavior">
          <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
            httpGetBindingConfiguration="" />            
          <serviceDebug includeExceptionDetailInFaults="true" />          
        </behavior>
      </serviceBehaviors>        
    </behaviors>
      <bindings>
          <webHttpBinding>
              <binding name="WebHttpSettings" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">                  
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </binding>
          </webHttpBinding>
      </bindings>   

3 个答案:

答案 0 :(得分:0)

您需要在服务行为中再设置一个设置:

<dataContractSerializer maxItemsInObjectGraph="2147483647" />

答案 1 :(得分:0)

我的猜测是你的实际服务名称不是MyService,而是在名称空间中。

假设您正在使用.NET 4,实际服务正在使用默认绑定设置或65536来获取默认端点。将service元素中的名称更改为服务实现类的完全限定类型名称

答案 2 :(得分:0)

好的,这个修复程序对每个人都不起作用,但对我来说,我通过省略名称而使我的配置成为webHttp的默认设置。这是修改后的配置。

 <services>
        <service name="MyService" behaviorConfiguration="HTTPMetadataBehavior">
            <endpoint address="http://localhost:2624" binding="webHttpBinding"
              bindingConfiguration="" contract="IMyService" />
        </service>
    </services>
 <behaviors>
      <serviceBehaviors>
        <behavior name="HTTPMetadataBehavior">
          <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
            httpGetBindingConfiguration="" />            
          <serviceDebug includeExceptionDetailInFaults="true" />          
        </behavior>
      </serviceBehaviors>        
    </behaviors>
      <bindings>
          <webHttpBinding>
              <binding name="" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">                  
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </binding>
          </webHttpBinding>
      </bindings>