[英]WCF communication problem
在我的 WCF 应用程序中,我收到了 base64String 格式的图像以及其他一些图像。为了测试我的应用程序,我创建了一个 small.aspx 页面,它将把名字、姓氏和 base64string(image:size 10Kb) 发送到 WCF服务。 我收到错误“格式化程序在尝试反序列化消息时引发异常:反序列化操作'SaveData'的请求消息正文时出错。读取XML数据时已超出最大字符串内容长度配额(8192)。此配额可以通过更改创建 XML 阅读器时使用的 XmlDictionaryReaderQuotas object 上的 MaxStringContentLength 属性来增加。第 1 行,position 153。
如果我发送没有 base64string(image) 的字符串,我能够调试 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>
在 web.config 文件中的Binding
标记内添加这些行
<binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" />
</binaryMessageEncoding>
<httpTransport decompressionEnabled="True" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"/>
希望这有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.