2014-10-20 118 views
0

請不要刪除此消息作爲重複!遠程服務器返回錯誤:(413)請求實體太大

我正在編寫一個WCF服務,允許上傳XML文件,以便將它們導入到數據庫中。但是,當我上傳64k以上的文件時,我收到了上述錯誤。

我已經閱讀了所有已發佈在此處的關於此問題的問題並已實施,但仍面臨同樣的問題。

我已經增加了我的配置文件中的所有綁定值(對於客戶端和服務器),以接受最大大小爲2GB。



    <binding name="BasicHttpBinding_BailiffServices" 
        maxBufferSize="2147483647" 
        maxBufferPoolSize="2147483647" 
        maxReceivedMessageSize="2147483647"> 
       <readerQuotas maxDepth="2147483647" 
          maxStringContentLength="2147483647" 
          maxArrayLength="2147483647" 
          maxBytesPerRead="2147483647" 
          maxNameTableCharCount="2147483647" /> 
       &ltsecurity mode="None" /> 

下面是使用綁定的WCF服務。



    <services> 
      <service name="ClientService.ClientService"> 
      <endpoint address="http://subversion/BusinessTier.Services.ClientService.svc" 
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_BailiffServices" 
       name="BasicHttpBinding_IClient" contract="ClientService.IClient" /> 
      </service> 
      <service name="DebtorService.DebtorService"> 
      <endpoint address="http://subversion/BusinessTier.Services.DebtorService.svc" 
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_BailiffServices" 
       name="BasicHttpBinding_IDebtor" contract="DebtorService.IDebtor" /> 
      </service> 
     </services> 

我還在設置中添加了設置,以確保IIS也能夠處理大文件。



    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"/> 
     <security> 
      <requestFiltering allowDoubleEscaping="true"> 
      <requestLimits maxAllowedContentLength="2147483647"/> 
      <fileExtensions allowUnlisted="true"/> 
      <verbs allowUnlisted="true"/> 
      </requestFiltering> 
     </security> 
     </system.webServer> 

至於我可以看到我已經修改了所有必要的設置,讓我的WCF服務以接受大文件,但他們都沒有到目前爲止的工作。

任何建議將不勝感激。

+1

異常的調用堆棧在哪裏?它是服務器端還是客戶端異常? – 2014-10-20 10:53:16

+0

這是一個服務器端異常。 – DomBurf 2014-10-20 10:54:25

+0

我最終設法在經過幾個小時的頭部劃傷後才能正常工作。我從元素和元素中刪除了綁定名稱BasicHttpBinding_BailiffServices£我在MSDN網站上偶然發現了這個解決方案,希望這可以幫助別人 – DomBurf 2014-10-20 16:07:05

回答

-1

我最終設法在幾個小時的頭部劃傷之後得到這個工作。我從<綁定/ >元素和<端點/ >元素中刪除了綁定名稱「BasicHttpBinding_BailiffServices」。我在MSDN網站上偶然發現了這個解決方案。希望這可以幫助別人。

+3

這沒有任何意義 - 如果你刪除了綁定配置,你應該獲得'basicHttpBinding'的默認較低值。你能鏈接到提供解決方案的MSDN站點嗎? – Tim 2014-10-20 18:20:49

0

我找到了解決方案,以避免錯誤,如'遠程服務器返回意外的響應:(413)請求實體太大。' 在WCF服務配置中使用basicHttpBinding時您只需增加Web.config中的最大消息長度即可。您可以更新服務器web.config和客戶端app.config文件以通過wcf發送大型字節數組。

包括以下綁定和行爲參數在Web.config中

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding maxReceivedMessageSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00"> 
     <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647"/> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior> 
     <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<protocolMapping> 
    <add binding="basicHttpsBinding" scheme="https" /> 
</protocolMapping> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"> 
    <serviceActivations> 
    <add factory ="WebService.NInjectServiceHostFactory" relativeAddress="TestServic.svc" service="WebService.Services.ServiceManager"/> 
    </serviceActivations> 
</serviceHostingEnvironment> 

我還增加了在客戶端app.config文件綁定配置。

<system.serviceModel> 
<bindings> 
<basicHttpBinding> 
    <binding name="BasicHttpBinding_IServiceManager" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> 
    <security mode="None"/> 
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
    </binding> 
</basicHttpBinding> 
</bindings> 

<client> 
<endpoint address="http://localhost:49359/ServiceManager.svc" 
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPackageManager" 
contract="PackageManager.IPackageManager" name="BasicHttpBinding_IPackageManager" /> 
</client> 

</system.serviceModel> 

這也將處理超時錯誤。

相關問題