格式化程序尝试对消息反序列化时引发异常: 对操作“GetData”的请求消息正文进行反序列化时出现错误。读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。 行 1,位置 10125。一直出现这个错误,怎么修改都不正确。
网上也搜了下,找到的修改办法试了也不起作用。
下面是我根据网上找的一些内容做的一些修改,但是运行起来还是出问题,求指导。运行环境,win7,vs2010,mvc3服务器端代码:namespace WcfService
{
public class Service1 : IService1
{
public int GetData(string value)
{
value = value == null ? "" : value;
return value.Length;
}
}
}
namespace WcfService
{
[ServiceContract]
public interface IService1
{
[OperationContract]
int GetData(string value);
}}客户端代码:Service1Client wcf_client = new Service1Client();
string itemstr = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
string teststr = "";
for (int i = 0; i < 100; i++)
{
teststr += itemstr;
} int b = teststr.Length;
int a = wcf_client.GetData(teststr);
wcf_client.Close();
服务器端配置:<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="A">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors> <services>
<service behaviorConfiguration="A" name="WcfService.IService1.GetData">
<endpoint address="" bindingConfiguration="BBB" binding="basicHttpBinding" contract="WcfService.IService1.GetData"/>
</service>
</services> <bindings>
<basicHttpBinding>
<binding name="BBB" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
客户端配置:<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" 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:2382/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="wcfService.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
WCF .net8192 WCF String8192
网上也搜了下,找到的修改办法试了也不起作用。
下面是我根据网上找的一些内容做的一些修改,但是运行起来还是出问题,求指导。运行环境,win7,vs2010,mvc3服务器端代码:namespace WcfService
{
public class Service1 : IService1
{
public int GetData(string value)
{
value = value == null ? "" : value;
return value.Length;
}
}
}
namespace WcfService
{
[ServiceContract]
public interface IService1
{
[OperationContract]
int GetData(string value);
}}客户端代码:Service1Client wcf_client = new Service1Client();
string itemstr = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
string teststr = "";
for (int i = 0; i < 100; i++)
{
teststr += itemstr;
} int b = teststr.Length;
int a = wcf_client.GetData(teststr);
wcf_client.Close();
服务器端配置:<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="A">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors> <services>
<service behaviorConfiguration="A" name="WcfService.IService1.GetData">
<endpoint address="" bindingConfiguration="BBB" binding="basicHttpBinding" contract="WcfService.IService1.GetData"/>
</service>
</services> <bindings>
<basicHttpBinding>
<binding name="BBB" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None"></security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
客户端配置:<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" 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:2382/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="wcfService.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
WCF .net8192 WCF String8192
解决方案 »
- 怎么使用App_Data中的数据库
- 我正在学习.net2.0,请问这是什么意思?
- web控间设置为autopostback时的问题
- 关于Request.InputStream的问题
- 关于设置权限的问题!大家有没有好的例子(WEB 最好是VB的,C#的也可以)在线等 有马上接分
- .NET 将数据库里的数据,以对象的方式取出来.
- 快速搜索页面上的控件并转换成相应的SQL
- 新手学习asp.net,推荐一本好书给我
- 谢谢hgknight(江雨.net)不厌其烦的帮我解决了一系列的问题,大家可以进来看看,会有收获的.特散分!
- 菜鸟问题? http://PostNew.asp?room=5202 如何用 javascript 获得 room 的值?
- 关于XML插入数据库
- Forms身份验证
<services>
<service behaviorConfiguration="A" name="WcfService.IService1.GetData">
<endpoint address="" bindingConfiguration="BBB" binding="basicHttpBinding" contract="WcfService.IService1.GetData"/>
</service>
</services>service 的name属性只需要写到命名空间+类名就可以了,不需要具体到方法名。
endpoint 的contract属性同样只需要命名空间+接口名就行了。