简体   繁体   English

WCF (413) 请求实体太大

[英]WCF (413) Request Entity too Large

Getting the error only on Uploading a byte[] of nearly 250k but downloading of the same byte[] array are fin using the same config.仅在上传近 250k 的 byte[] 但下载相同的 byte[] 数组时才出现错误,使用相同的配置即可。

I've looked into Streaming but the single parameter doesnt work and these file sizes are huge.我研究了 Streaming,但单个参数不起作用,而且这些文件大小很大。 I have been able to upload a simple text file of 630 bytes and it works fine.我已经能够上传一个 630 字节的简单文本文件,它工作正常。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
          <binding name="BasicHttpBinding_IGenerateLetterWcf"
                   maxBufferSize="20000000" maxReceivedMessageSize="20000000"
                   closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" >
            <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </binding>
        </basicHttpBinding>
    </bindings>
    <client>         
        <endpoint address="http://localhost:61394/GenerateLetterWcf.svc" 
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGenerateLetterWcf" 
            contract="GenerateLetterWcfSvc.IGenerateLetterWcf" name="BasicHttpBinding_IGenerateLetterWcf" />          
    </client>
</system.serviceModel>
</configuration>
    <?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="DTPLibrary.Properties.Settings.XXXXConnectionString1" connectionString="data source=XXXXX;initial catalog=XXXXXX;User ID=SQLAdmin;Password=XXXXXX" providerName="System.Data.SqlClient"/>
  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.net>
    <settings>
      <servicePointManager expect100Continue="false"/>
    </settings>
  </system.net>
  <system.serviceModel>
    <diagnostics>
    <messageLogging
         logEntireMessage="true"
         logMalformedMessages="true"
         logMessagesAtServiceLevel="true"
         logMessagesAtTransportLevel="true"
         maxMessagesToLog="3000000"
         maxSizeOfMessageToLog="2000000"/>
  </diagnostics>

    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IEntitySearchWcf" maxBufferSize="10000000" maxReceivedMessageSize="10000000" closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" />
        <binding name="BasicHttpBinding_IBrokerWcf" maxBufferSize="6500000" maxReceivedMessageSize="6500000" />
        <binding name="BasicHttpBinding_IProjectWcf" maxBufferSize="9900000" maxReceivedMessageSize="9900000" />
        <binding name="BasicHttpBinding_ILoginWcf" maxReceivedMessageSize="20000000" maxBufferSize="20000000" /> 
        <binding name="BasicHttpBinding_ISupportWcf" maxBufferSize="9900000" maxReceivedMessageSize="9900000" />
        <binding name="BasicHttpBinding_IInscoWcf" maxBufferSize="100000000" maxReceivedMessageSize="100000000" />
        <binding name="BasicHttpBinding_IClientMaintenanceWcf" maxReceivedMessageSize="9900000" />
        <binding name="BasicHttpBinding_IWebUserWcf" maxReceivedMessageSize="9900000" />
        <binding name="BasicHttpBinding_IRoleWcf" maxReceivedMessageSize="9900000" />
        <binding name="BasicHttpBinding_ILabelWcf" maxReceivedMessageSize="10000000" maxBufferSize="10000000" />
        <binding name="BasicHttpBinding_IProjectTypeWcfSvc" maxReceivedMessageSize="9900000" />
        <binding name="BasicHttpBinding_IDropDownWcf" maxBufferSize="100000000" maxReceivedMessageSize="100000000" />
        <binding name="BasicHttpBinding_IDefaultCertLimitWcf" maxBufferSize="100000000" maxReceivedMessageSize="100000000" />
        <binding name="BasicHttpBinding_IConfigurationWcf" />
        <binding name="BasicHttpBinding_IEndorsementsWcf" />
        <binding name="BasicHttpBinding_IProjectCertReqWcf" maxBufferSize="2000000000" maxReceivedMessageSize="2000000000" />
        <binding name="BasicHttpBinding_IInsuredEntryWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
        <binding name="BasicHttpBinding_ICertWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
        <binding name="BasicHttpBinding_IDocumentWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
        <binding name="BasicHttpBinding_IReportsWcf" />
        <binding name="BasicHttpBinding_ICertGenLetterTemplWcf" />
        <binding name="BasicHttpBinding_IGenerateLetterWcf" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"  
                 closeTimeout="00:20:00" openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" 
                 />
        <binding name="BasicHttpBinding_ILinkImagesWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
        <binding name="BasicHttpBinding_IErrorLogWcf" />
        <binding name="BasicHttpBinding_IDashBoardWcf" />
        <binding name="BasicHttpBinding_IReviewScannedCertificateWcf" maxBufferSize="1000000000" maxReceivedMessageSize="1000000000" />
        <binding name="BasicHttpBinding_IAllEndorsementsWcf" />
        <binding name="BasicHttpBinding_IScanDocumentWcf" />
        <binding name="BasicHttpBinding_IUserWcf" />
        <binding name="BasicHttpBinding_IOutputLogWcf" />
        <binding name="BasicHttpBinding_IStreamServiceWcf" closeTimeout="00:20:00"
            openTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
            maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
            maxReceivedMessageSize="2147483647" transferMode="Streamed" messageEncoding="Mtom"/>        
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:61394/EntitySearchWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEntitySearchWcf" contract="EntitySearchWcfSvc.IEntitySearchWcf" name="BasicHttpBinding_IEntitySearchWcf" />
      <endpoint address="http://localhost:61394/BrokerWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IBrokerWcf" contract="BrokerWcfSvc.IBrokerWcf" name="BasicHttpBinding_IBrokerWcf" />
      <endpoint address="http://localhost:61394/ProjectWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProjectWcf" contract="ProjectWcfSvc.IProjectWcf" name="BasicHttpBinding_IProjectWcf" />
      <endpoint address="http://localhost:61394/SupportWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISupportWcf" contract="SupportWcfSvc.ISupportWcf" name="BasicHttpBinding_ISupportWcf" />
      <endpoint address="http://localhost:61394/LoginWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILoginWcf" contract="LoginWcfSvc.ILoginWcf" name="BasicHttpBinding_ILoginWcf" />
      <endpoint address="http://localhost:61394/InscoWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IInscoWcf" contract="InscoWcfSvc.IInscoWcf" name="BasicHttpBinding_IInscoWcf" />
      <endpoint address="http://localhost:61394/ClientMaintenanceWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IClientMaintenanceWcf" contract="ClientMaintenanceWcfSvc.IClientMaintenanceWcf" name="BasicHttpBinding_IClientMaintenanceWcf" />
      <endpoint address="http://localhost:61394/WebUserWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWebUserWcf" contract="WebUserWcfSvc.IWebUserWcf" name="BasicHttpBinding_IWebUserWcf" />
      <endpoint address="http://localhost:61394/RoleWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRoleWcf" contract="RoleWcfSvc.IRoleWcf" name="BasicHttpBinding_IRoleWcf" />
      <endpoint address="http://localhost:61394/LabelWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILabelWcf" contract="LabelWcfSvc.ILabelWcf" name="BasicHttpBinding_ILabelWcf" />
      <endpoint address="http://localhost:61394/ProjectTypeWcfSvc.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProjectTypeWcfSvc" contract="ProjectTypeWcfSvc.IProjectTypeWcfSvc" name="BasicHttpBinding_IProjectTypeWcfSvc" />
      <endpoint address="http://localhost:61394/DefaultCertLimitWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDefaultCertLimitWcf" contract="DefaultCertLimitWcfSvc.IDefaultCertLimitWcf" name="BasicHttpBinding_IDefaultCertLimitWcf" />
      <endpoint address="http://localhost:61394/DropDownWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDropDownWcf" contract="DropDownWcfSvc.IDropDownWcf" name="BasicHttpBinding_IDropDownWcf" />
      <endpoint address="http://localhost:61394/ConfigurationWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IConfigurationWcf" contract="ConfigurationWcfSvc.IConfigurationWcf" name="BasicHttpBinding_IConfigurationWcf" />
      <endpoint address="http://localhost:61394/EndorsementsWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEndorsementsWcf" contract="EndorsementsWcfSvc.IEndorsementsWcf" name="BasicHttpBinding_IEndorsementsWcf" />
      <endpoint address="http://localhost:61394/ProjectCertReqWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProjectCertReqWcf" contract="ProjectCertReqWcfSvc.IProjectCertReqWcf" name="BasicHttpBinding_IProjectCertReqWcf" />
      <endpoint address="http://localhost:61394/InsuredEntryWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IInsuredEntryWcf" contract="InsuredEntryWcfSvc.IInsuredEntryWcf" name="BasicHttpBinding_IInsuredEntryWcf" />
      <endpoint address="http://localhost:61394/CertWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICertWcf" contract="CertWcfSvc.ICertWcf" name="BasicHttpBinding_ICertWcf" />
      <endpoint address="http://localhost:61394/DocumentWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDocumentWcf" contract="DocumentWcfSvc.IDocumentWcf" name="BasicHttpBinding_IDocumentWcf" />
      <endpoint address="http://localhost:61394/ReportsWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReportsWcf" contract="ReportsWcfSvc.IReportsWcf" name="BasicHttpBinding_IReportsWcf" />
      <endpoint address="http://localhost:61394/CertGenLetterTemplWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICertGenLetterTemplWcf" contract="CertGenLetterTemplWcfSvc.ICertGenLetterTemplWcf" name="BasicHttpBinding_ICertGenLetterTemplWcf" />
      <endpoint address="http://localhost:61394/GenerateLetterWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGenerateLetterWcf" contract="GenerateLetterWcfSvc.IGenerateLetterWcf" name="BasicHttpBinding_IGenerateLetterWcf" />
      <endpoint address="http://localhost:61394/LinkImagesWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILinkImagesWcf" contract="LinkImagesWcfSvc.ILinkImagesWcf" name="BasicHttpBinding_ILinkImagesWcf" />
      <endpoint address="http://localhost:61394/ErrorLogWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IErrorLogWcf" contract="ErrorLogWcfSvc.IErrorLogWcf" name="BasicHttpBinding_IErrorLogWcf" />
      <endpoint address="http://localhost:61394/DashBoardWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDashBoardWcf" contract="DashboardWcfSvc.IDashBoardWcf" name="BasicHttpBinding_IDashBoardWcf" />
      <endpoint address="http://localhost:61394/ReviewScannedCertificateWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReviewScannedCertificateWcf" contract="ReviewScannedCertificateWcfSvc.IReviewScannedCertificateWcf" name="BasicHttpBinding_IReviewScannedCertificateWcf" />
      <endpoint address="http://localhost:61394/AllEndorsementsWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAllEndorsementsWcf" contract="AllEndorsementsWcfSvc.IAllEndorsementsWcf" name="BasicHttpBinding_IAllEndorsementsWcf" />
      <endpoint address="http://localhost:61394/ScanDocumentWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IScanDocumentWcf" contract="ScanDocumentWcfSvc.IScanDocumentWcf" name="BasicHttpBinding_IScanDocumentWcf" />
      <endpoint address="http://localhost:61394/UserWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserWcf" contract="UserWcfSvc.IUserWcf" name="BasicHttpBinding_IUserWcf" />
      <endpoint address="http://localhost:61394/OutputLogWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IOutputLogWcf" contract="OutputLogWcfSvc.IOutputLogWcf" name="BasicHttpBinding_IOutputLogWcf" />
      <endpoint address="http://localhost:61394/StreamServiceWcf.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStreamServiceWcf" contract="StreamServiceWcfSvc.IStreamServiceWcf" name="BasicHttpBinding_IStreamServiceWcf" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="1365536" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"  />
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true"   maxReceivedMessageSize="65536000"/>
      </webHttpEndpoint>
    </standardEndpoints>  
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>

  </system.webServer>


  <system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="messages"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="c:\logs\messages.svclog" />
        </listeners>
      </source>
      <source name="System.ServiceModel"
              switchValue="Warning, Critical, Error, Verbose"
              propagateActivity="true">
        <listeners>
          <add name="sdt"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "c:\logs\service.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

</configuration>

I have a question about your present configuration.我对您目前的配置有疑问。 Why you use the absolute service address in your endpoint address?为什么在端点地址中使用绝对服务地址? if the service is hosted in IIS, the base address is provided by the IIS site binding module.如果服务托管在 IIS 中,则基地址由 IIS 站点绑定模块提供。
在此处输入图像描述
Thereby I suspect the current live connection doesn't use this endpoint address, which results in the failure of the MaxReceivedMessageSize setting.因此我怀疑当前的实时连接没有使用这个端点地址,这会导致 MaxReceivedMessageSize 设置失败。 I would like to know what the service address the client actually used is.我想知道客户端实际使用的服务地址是什么。 Only apply the configuration on the correct service endpoint address can take effect.只有在正确的服务端点地址上应用配置才能生效。
Feel free to let me know if the problem still exists.如果问题仍然存在,请随时告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM