2012-09-19 68 views
0

我得到一個錯誤WCF配置固定字符串的最大內容長度配額(8192)已超過

最大字符串內容長度配額(8192)已超過

我知道我需要修改我的WCF配置,但我無法正常工作。以下是我到目前爲止的內容:我嘗試使用內置的WCF編輯器。

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 

    <client> 
     <remove contract="IMetadataExchange" name="sb" /> 
     <endpoint address="" binding="netTcpRelayBinding" contract="IMetadataExchange" 
     name="sb" /> 
    </client> 
    <services> 
     <service name="SvcLibrary.Service1"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/SvcLibrary/Service1/"/> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="wsHttpBinding" contract="SvcLibrary.IService1"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <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="False"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

回答

2

SCB是正確的關於這又是綁定:

<bindings> 
     <wsHttpBinding> 
     <binding> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 

但我也得到錯誤「的最大字符串內容長度配額(8192)有已被超過「,因爲我需要修改客戶端應用程序,如下所示:

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

默認maxStringContentLength設置爲8192我把它提高到65536,問題就解決了

1

你需要改變你的結合部分,如下所示:

<bindings> 
     <wsHttpBinding> 
     <binding maxReceivedMessageSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 

您的端點指定它正在使用的wsHttpBinding但你只配置了basicHttpBinding的。

這意味着,您的服務將只使用默認值

順便說您指定的值是巨大的,你可能要審查這些

- 更新

增加了maxReceivedMessageSize屬性綁定。

也可以確認您是否在客戶端進行了任何更改。基本上客戶端和服務器配置都應該匹配。

+0

我做了這個變化,但我仍然得到同樣的錯誤。我是否也需要編輯端點部分? – GoBeavs

+0

您是否刪除了綁定的名稱,所以與上面的名稱相同? – SCB

+0

現在看起來像這樣: <的wsHttpBinding> GoBeavs

0

您正在設置正確的屬性(maxStringContentLength),但綁定錯誤。問題在於您正在定義配置basicHttpBinding,但在服務端點上使用wsHttpBinding。將綁定配置更改爲wsHttpBinding並且它應該可以正常工作(您可能需要驗證是否需要通過wsHttpBinding提供的WS- *功能,還可以將端點的綁定更改爲basicHttpBinding,並且這也可以起作用,只要您不需要「噸需要支持分佈式事務等)

+1

仍在收到「最大字符串內容長度限額(8192)」 – GoBeavs

相關問題