2011-08-09 112 views
1

在我的WCF應用程序中,我收到一個base64String格式的圖像以及一些其他圖像。 爲了測試我的應用程序,我創建了一個小的.aspx頁面,它將發送名字,姓氏和base64string(圖像:大小10Kb)到WCF服務。 我收到錯誤 「格式化程序在嘗試反序列化消息時拋出異常: 反序列化操作'SaveData'的請求消息正文時出錯 在讀取XML時超出了最大字符串內容長度限額(8192)數據 通過更改創建XML閱讀器時使用的 XmlDictionaryReaderQuotas對象上的MaxStringContentLength屬性,可以增加此配額。第1行,位置15301.「WCF通信問題

如果我發送沒有base64string(圖片)的字符串,我可以調試wcf服務代碼。 但是,如果我添加base64String我得到這個錯誤。 我已將所有綁定值(「maxReceivedMessageSize」)和其他值增加到最大值。 我仍然收到此錯誤。這是我的web.config客戶端和服務。 謝謝,我真的很感謝你的幫助。

客戶的Web.config

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IRESTService1" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01: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:10255/RESTService1.svc" binding="basicHttpBinding" 
     bindingConfiguration="BasicHttpBinding_IRESTService1" contract="ServiceReference1.IRESTService1" 
     name="BasicHttpBinding_IRESTService1" /> 
    </client> 
    </system.serviceModel> 

服務的web.config

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

    </bindings> 
    <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> 

    <services> 
     <service name="RESTService1"> 
     <endpoint address="" 
      binding="basicHttpBinding" name="MainHttpPoint" contract="RESTService1" bindingConfiguration="BasicBinding1" />  
     </service> 
    </services> 

    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>--> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer> 

回答

1

添加這些行內Binding標記在web.config文件

<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"> 
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" /> 
</binaryMessageEncoding> 
<httpTransport decompressionEnabled="True" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"/> 

MSDN : binaryMessageEncoding

希望這可以幫到

+0

Hi Amani,謝謝你的回覆。但它不允許我在標籤內添加標籤。任何想法我應該添加它。 – Henry

+0

我的朋友我說過綁定標籤,而不是綁定。 – saber