编码器,这个问题快把我逼疯了!!在过去的两天里,我一直在做大量的研究,我不知道发生了什么。
问题:如标题所示,有一个WCF服务,由silverlight应用程序使用。问题是,每当我尝试使用WCF操作之一时,我都会收到以下错误:
读取XML数据时超过了最大字符串内容长度配额(8192)。
我知道我应该将MaxStringContentLength在web.config中的值更改为适合我的消息大小的值,但在我看来,更新MaxStringContentLength的值并没有反映在系统中。我试图更新服务引用,重新构建了整个解决方案,结果仍然是相同的错误。知道我该怎么做吗?
解决方案信息:
与WCF folder.
的
Web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding
name="BasicHttpBinding_Service1"
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="10000"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:53931/WCF/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Service1"
contract="ServiceReference.Service1"
name="BasicHttpBinding_Service1" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding
name="BasicHttpBinding_Service1"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
>
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:53931/WCF/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Service1"
contract="ServiceReference.Service1"
name="BasicHttpBinding_Service1" />
</client>
</system.serviceModel>
提前谢谢。
发布于 2011-01-18 05:58:41
我没有看到在web.config文件中任何地方定义的服务--那里只有一个服务客户端定义。我很惊讶这项服务竟然是这样运作的。复制和粘贴错误?
下面是类似场景的web.config (您缺少标记的部分):
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="MyDefaultBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MyDefaultBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000">
<readerQuotas maxDepth="500" maxArrayLength="20000000" maxStringContentLength="20000000"/>
</binding>
</basicHttpBinding>
</bindings>
<services> <!-- This appears missing from your web.config -->
<service behaviorConfiguration="MyDefaultBehavior" name="MyProject.MyService">
<endpoint address="" binding="basicHttpBinding" contract="MyProject.IMyService" bindingConfiguration="MyDefaultBinding" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>https://stackoverflow.com/questions/4720875
复制相似问题