2013-03-11 175 views
2

我知道這是一個多餘的問題,我在上傳大於100 KB的文件時出現錯誤。遠程服務器返回錯誤:(413)請求實體太大

The remote server returned an error: (413) Request Entity Too Large.

我將內容發佈到WCF服務(64位環境)。我知道這應該已經通過管理maxReceivedMessageSize和相關行爲來解決,但不幸的是它沒有。

下面是我的配置: -

客戶

 <binding allowCookies="false" bypassProxyOnLocal="false" closeTimeout="00:01:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" name="BasicHttpBinding_ICandidateManagementService" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:11:00" textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
      <message algorithmSuite="Default" clientCredentialType="UserName"/> 
      </security> 
     </binding> 

<behavior name="CandidateBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 

<endpoint address="http://localhost:62368/CandidateManagementService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICandidateManagementService" contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" name="BasicHttpBinding_ICandidateManagementService" behaviorConfiguration="CandidateBehavior" /> 

服務

<services> 
     <service name="BasicHttpBinding_ICandidateManagementService" behaviorConfiguration="CandidateBehavior"> 
     <endpoint contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" binding="basicHttpBinding" address="" bindingConfiguration="BasicHttpBinding_ICandidateManagementService"/> 
     </service> 

我所看到的一切可能提供與斜面仍然解決這個問題。也嘗試過使用下面的配置,但仍然沒有變化...

<serverRuntime uploadReadAheadSize="500000000" maxRequestEntityAllowed="500000000"/> 

請幫忙!

服務綁定配置(其作爲客戶端相同)

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

爲了讓下面更深入的瞭解是小提琴手發現: -

Request Count: 1 Bytes Sent: 85,719 (headers:697; body:85,022) Bytes Received: 10,129 (headers:254; body:9,875)

+0

我以爲你還需要在IIS中設置一些東西,但不知道肯定。 – 2013-03-11 13:40:56

+0

我不這麼認爲,如果你遇到任何問題,請告訴我。 – Wali 2013-03-11 16:14:45

+0

我在Chrome上檢索到相同的錯誤。當我切換到Firefox時,所有問題都消失了。 – 2016-12-16 19:13:00

回答

3

最後我的問題所困擾了很多之後得到解決。 我的服務配置有一個缺陷,它沒有給我任何運行時或編譯時錯誤,因爲它甚至沒有識別配置。

我的服務配置爲: -

<services> 
     <service name="BasicHttpBinding_ICandidateManagementService" behaviorConfiguration="CandidateBehavior"> 
     <endpoint contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" binding="basicHttpBinding" address="" bindingConfiguration="BasicHttpBinding_ICandidateManagementService"/> 
     </service> 

我有「名稱」屬性,它不是我服務的全名,因此我所用甚至沒有考慮,因此正在採取默認的65KB配置爲maxReceivedMessageSize。

我已更新它,它的工作就像一個魅力。

<services> 
    <service name="MMJ.Services.CandidateManagementService"> 
    <endpoint contract="MMJ.ServiceContracts.ServiceContract.ICandidateManagementService" binding="basicHttpBinding" address="" bindingConfiguration="BasicHttpBinding_ICandidateManagementService"/> 
    </service> 

另外,看看這個post爲更多的參考。我知道這是一個愚蠢的錯誤,並且感謝大家努力修復。

+0

您的問題對我有幫助。我有同樣的問題,但只是使用'maxReceivedMessageSize =「2000000」'解決。 – 2014-01-20 13:04:38

1

你的數據發佈到服務器,因此更新客戶端設置將無濟於事。客戶端不是接收大消息的服務器。

+0

我同意...我已經更新了服務器配置。它仍然沒有產生任何結果。 – Wali 2013-03-11 16:14:01

+0

你可以發佈配置的「BasicHttpBinding_ICandidateManagementService」部分嗎? – Rich 2013-03-11 17:07:04

+0

它已經發布在我的問題...我再次張貼... – Wali 2013-03-11 17:29:27

0

看你的客戶端點:

不應該bindingConfiguration是

bindingConfiguration="BasicHttpBinding_ICandidateManagementService" 

而不是

bindingConfiguration="BasicHttpBinding_IAdminService" 
+0

這只是一個錯誤的錯誤,我正在使用正確的配置。 – Wali 2013-03-12 03:57:05

+0

您是爲您的傳輸模式進行流式傳輸還是緩存(是您的參數/響應流類型)?根據你的配置,你正在做緩衝服務,但在客戶端流式傳輸。我認爲他們在每一端都必須是相同的,否則它將如何知道如何分塊呢?你有/你可以試着讓它們相同,並再次嘗試一下,看看它是否有效? – 2013-03-12 15:09:14

+0

我檢查過了,我在服務器和客戶端都使用了緩衝區。由於在我的實現中沒有流式傳輸的概念。 – Wali 2013-03-12 18:01:47

相關問題