.net WCF服务400错误请求

.net WCF服务400错误请求,.net,wcf,exception,.net,Wcf,Exception,我创建了一个接收大文件的服务。在那之后,我把它发表在我当地的IIS7上。之后,我创建了带有服务引用的测试客户机。当我试图向服务器发送大文件时,我得到了:错误的请求(400) 该异常的服务跟踪: 已超过传入邮件的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。 服务器配置: <system.web> <compilation debug="true" targetFramework="4.0" />

我创建了一个接收大文件的服务。在那之后,我把它发表在我当地的IIS7上。之后,我创建了带有服务引用的测试客户机。当我试图向服务器发送大文件时,我得到了:错误的请求(400)

该异常的服务跟踪: 已超过传入邮件的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。

服务器配置:

  <system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true" executionTimeout="14400"/>
<customErrors mode="Off" /></system.web>

装订

      <wsHttpBinding>
    <binding name="wsBufferedHttpsBinding" messageEncoding="Mtom" 
             maxReceivedMessageSize="11534336" maxBufferPoolSize="524288"
             sendTimeout="00:05:00" receiveTimeout="00:05:00" openTimeout="00:05:00" closeTimeout="00:05:00" >
      <readerQuotas maxDepth="64" maxStringContentLength="11534336" maxArrayLength="11534336"
          maxBytesPerRead="11534336" maxNameTableCharCount="16384" />
    </binding>
  </wsHttpBinding>

服务

      <service name="MyService">
    <endpoint address=""
              binding="wsHttpBinding"
              bindingName="wsBufferedHttpsBinding"
              contract="IServiceContract">
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    <endpoint address="soap12IssuedToken" binding="customBinding"
      bindingConfiguration="soap12IssuedToken" name="soap12IssuedToken"
      bindingNamespace="http://url"
      contract="IServiceContract" />
  </service>


这项服务到底出了什么问题?我在任何地方都设置了此消息大小。

看起来主要问题是您的端点没有引用绑定配置。因此,您使用的是默认的65536

还有一些其他事项需要检查:

  • 同一合约有两个端点,是否使用设置了maxReceivedMessageSize的端点
  • 客户端上的配置与服务器上的配置匹配吗
  • 您可能还需要设置“maxBufferPoolSize”和“maxBufferSize”

    • 答案很简单:

       <endpoint address=""
                binding="wsHttpBinding"
                bindingName="wsBufferedHttpsBinding"
                contract="IServiceContract">
      
      
      

      我没有看到有bindingName而不是bindingConfiguration

      我后来也遇到了这个问题,但后来我通过添加
      dataContractSerializer maxItemsInObjectGraph=“2147483646”在服务的行为中

      要传输的文件有多大?使用它可能会有所帮助。忘了说-发送1mb文件时失败。我发现关于这个问题的这个非常有趣的评论:。但在我的跟踪中没有“未找到端点”消息