2010-05-25 62 views
7

我的WCF服務有一個OperationContract,它接受一個對象數組作爲參數。這可能會相當大。在查找Bad Request:400的修復程序後,我找到了真正的原因:最大的消息大小。傳入郵件的最大郵件大小限額(65536)已被超出

我知道這個問題已經在很多地方被問過。我試過每個人都說:「增加客戶端和服務器配置文件的大小。」我有。它仍然不起作用。

我服務的web.config:

<system.serviceModel> 
    <services> 
     <service name="myService"> 
     <endpoint name="myEndpoint" address="" 
        binding="basicHttpBinding" 
        bindingConfiguration="myBinding" 
        contract="Meisel.WCF.PDFDocs.IPDFDocsService" /> 
     </service> 
    </services> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="myBinding" 
       closeTimeout="00:11:00" 
       openTimeout="00:11:00" 
       receiveTimeout="00:15:00" 
       sendTimeout="00:15:00" 
       maxBufferSize="2147483647" 
       maxReceivedMessageSize="2147483647" 
       maxBufferPoolSize="2147483647" 
       transferMode="Buffered" 
       allowCookies="false" 
       bypassProxyOnLocal="false" 
       hostNameComparisonMode="StrongWildcard" 
       messageEncoding="Text" 
       textEncoding="utf-8" 
       useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" 
         maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" 
         maxBytesPerRead="2147483647" 
         maxNameTableCharCount="2147483647" /> 
      <security mode="None" /> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

我的客戶的app.config:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IPDFDocsService" 
       closeTimeout="00:11:00" 
       openTimeout="00:11:00" 
       receiveTimeout="00:10:00" 
       sendTimeout="00:11:00" 
       allowCookies="false" 
       bypassProxyOnLocal="false" 
       hostNameComparisonMode="StrongWildcard" 
       maxBufferSize="2147483647" 
       maxBufferPoolSize="2147483647" 
       maxReceivedMessageSize="2147483647" 
       messageEncoding="Text" 
       textEncoding="utf-8" 
       transferMode="Buffered" 
       useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="32" 
         maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" 
         maxBytesPerRead="2147483647" 
         maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" 
         proxyCredentialType="None" 
         realm="" /> 
      <message clientCredentialType="UserName" 
        algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8451/PDFDocsService.svc" 
       behaviorConfiguration="MoreItemsInObjectGraph" 
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_IPDFDocsService" 
       contract="PDFDocsService.IPDFDocsService" 
       name="BasicHttpBinding_IPDFDocsService" /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="MoreItemsInObjectGraph"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647" /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 

我能可能被丟失或做錯了什麼?就好像該服務忽略了我在maxReceivedBufferSize中輸入的內容。

由於提前, 凱爾

UPDATE

這裏是他們從來沒有收到答覆其他兩個StackOverflow的問題,無論是:

https://stackoverflow.com/questions/2880623/maxreceivedmessagesize-adjusted-but-still-getting-the-quotaexceedexception-with

WCF MaxReceivedMessageSize property not taking

+0

它看起來正確一目瞭然。你是否在代碼中配置了終點?如果是這樣,那可能會覆蓋配置設置。 – 2010-05-25 22:07:42

+0

你是如何託管這項服務的? IIS? – 2010-05-25 23:58:27

+0

@Jeff:我剛剛創建了一個新的服務客戶端實例,然後調用OperationContract,傳入我的自定義類作爲參數。沒有什麼花哨。 @Simon:我正在使用ASP .NET開發服務器。目前,它都是本地的。 – DaleyKD 2010-05-26 00:45:58

回答

7

在裏面服務配置文件,「名稱」屬性中,通過元素

<behaviors> 
    <serviceBehaviors> 
    <behavior name="StackOverflow"> 

失蹤,應該在服務元素添加到此名稱的引用:

<system.serviceModel> 
    <services> 
     <service behaviorConfiguration="StackOverflow" name="myService"> 
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding" 

一般情況下,這是個好主意使用從Visual Studio「工具」菜單項調用的「WCF服務配置編輯器」驗證(如果不是始終編輯)您的WCF配置文件。

此外,沒有爲該服務定義端點行爲。我不知道這是否重要。

+0

如果我告訴你,當我爲我的行爲添加一個名稱時,WCFTestClient會給我錯誤信息:「錯誤:無法獲取元數據。元數據包含無法解析的引用。 charset = utf-8不被服務支持,客戶端和服務綁定可能不匹配,遠程服務器返回一個錯誤:(415)Unsupported Media Type.HTTP GET .HTML文檔不包含Web服務發現信息。這就是爲什麼我沒有爲自己的行爲列入名字的原因。 – DaleyKD 2010-05-26 15:11:35

+0

我仍然不確定這個問題真正的解決方案是什麼,但是我能夠解決我的ORIGINAL問題,使這個問題沒有實際意義。 FWIW,看起來好像我能夠通過使SURE服務使用behaviorConfiguration來擺脫上述錯誤。謝謝! – DaleyKD 2010-05-26 19:53:51

0

我有與WCF測試相同的問題,我正確地設置了配置文件。如果你的配置文件沒有任何問題,我建議嘗試用另一個程序來測試服務,例如:SOAP UI,我認爲這個錯誤不是來自服務,而是來自WCF Test。

相關問題