读取XML数据时已超出最大字符串内容长度配额(8192)。

时间:2012-10-25 07:53:30

标签: string wcf max

我收到以下错误

  

服务器在处理请求时遇到错误。例外   消息是'格式化程序在尝试时抛出异常   反序列化消息:尝试时出错   反序列化参数http://tempuri.org/:commentText。该   InnerException消息是'反序列化时出错   System.String类型的对象。最大字符串内容长度配额   读取XML数据时已超出(8192)。这个配额可能是   通过更改上的MaxStringContentLength属性来增加   创建XML阅读器时使用的XmlDictionaryReaderQuotas对象。'。   有关更多详细信息,请参阅InnerException。'请参阅服务器日志了解更多   细节。异常堆栈跟踪是:

at 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)

而且这是我的web.config

<services>
      <service behaviorConfiguration="Frontiers.WCF.Services.MyHomeServiceBehavior" name="Frontiers.WCF.Services.MyHomeService">
        <endpoint address="" behaviorConfiguration="EndpBehavior" binding="webHttpBinding" contract="Frontiers.WCF.Services.IMyHomeService" />
      </service>
      <service behaviorConfiguration="Frontiers.WCF.Services.NetworkServiceBehavior" name="Frontiers.WCF.Services.NetworkService">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="EndpBehavior" contract="Frontiers.WCF.Services.INetworkService" >
        </endpoint>
      </service>
      <service behaviorConfiguration="Frontiers.WCF.Services.WidgetServiceBehaviour" name="Frontiers.WCF.Services.WidgetService">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="EndpBehavior" contract="Frontiers.WCF.Services.IWidgetService">
        </endpoint>
      </service>
      <service behaviorConfiguration="Frontiers.SharePoint.Site.Navigation.NavigationServiceBehaviour" name="Frontiers.SharePoint.Site.Navigation.NavigationService">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="EndpBehavior" contract="Frontiers.SharePoint.Site.Navigation.INavigationService">
        </endpoint>
      </service>
      <service behaviorConfiguration="Frontiers.WCF.Services.UserProfileServiceBehavior" name="Frontiers.WCF.Services.UserProfileService">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="EndpBehavior" contract="Frontiers.WCF.Services.IUserProfileService">
        </endpoint>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="ContactsImporterSoap" 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="819200" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="JournalActivityReportSoap" 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="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="eUtilsServiceSoap" 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="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="eUtilsServiceSoap1" 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="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="eUtilsServiceSoap2" 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="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="eUtilsServiceSoap3" 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="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

有人可以帮帮我吗?

2 个答案:

答案 0 :(得分:0)

你应该增加你的maxStringContentLength =“8192”,错误说它试图读取一个更高的字符串作为8192个字符。

答案 1 :(得分:0)

在服务主机的app.config中设置maxStringContentLength="8192"