2011-08-09 34 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