我是wcf服务的新手。
有些时候没有错误,但有时候会出错。请帮帮我
服务模式
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="ExStreamWCFBinding"
closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="wsServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="Wcf_tblt_rTest.Service1" behaviorConfiguration="ServiceBehavior" >
<host>
<baseAddresses>
<add baseAddress="http://localhost:900/mex/"/>
<add baseAddress="net.tcp://localhost:9000/" />
</baseAddresses>
</host>
<endpoint bindingConfiguration="ExStreamWCFBinding" binding="basicHttpBinding" contract="Wcf_tblt_rTest.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
错误就像这样
尝试反序列化参数http://tempuri.org/:tm时出错。 InnerException消息是'反序列化时出错 JSONSample.GetResp类型的对象。最大字符串内容长度 读取XML数据时已超过quota(8192)。这个配额可能 通过更改上的MaxStringContentLength属性来增加 创建XML阅读器时使用的XmlDictionaryReaderQuotas对象。'。 有关更多详细信息,请参阅InnerException。'请参阅服务器日志了解更多 细节。异常堆栈跟踪是:
在 System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader 读者,PartInfo部分)at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader 读者,PartInfo部分)at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader,PartInfo [] parts,Object []参数,PartInfo returnInfo, 对象和放大器; returnValue)at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBodyCore(XmlDictionaryReader reader,Object []参数,Boolean isRequest)at System.ServiceModel.Dispatcher.DataContractJsonSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader,MessageVersion版本,字符串操作,MessageDescription messageDescription,Object []参数,Boolean isRequest)at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(消息 message,Object []参数,布尔isRequest)at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(消息 消息,对象[]参数)at System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(消息 消息,对象[]参数)at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(消息 消息,对象[]参数)at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(消息 消息,对象[]参数)at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc&安培; rpc)at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&安培; rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&安培; rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&安培; rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&安培; rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&安培; rpc)at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&安培; rpc)at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
答案 0 :(得分:2)
WCF有许多配额(也就是限制),可以防止恶意或无意的拒绝服务攻击。
消息“已超出最大字符串内容长度配额(8192)”表示您发送的字符串包含超过8192个字符。您必须更改配置文件以允许更大的内容。
您的设置未在此处应用,因为您为 wsHttpBinding 指定了读者配额,并且您的服务通过 basicHttpBinding 公开:存在不匹配,并且未应用新的配额设置。< / p>