2012-10-02 21 views
1

的Web服务时,我有一个是本地托管的WCF服务。我的web.config看起来是这样的:如果我通过在不到8K的文本错误调用带有大量数据

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpBinding_INavigationService" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="6553600" maxBufferPoolSize="5242880" maxReceivedMessageSize="6553600" 
     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/WebServices/NavigationService.svc/" 
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INavigationService" 
    contract="NavigationService.INavigationService" name="BasicHttpBinding_INavigationService" /> 
</client> 
</system.serviceModel> 

我的服务工作正常。任何更多,我得到以下错误:

Sys.WebForms.PageRequestManagerServerErrorException: The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'UpdateSiteMap'. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 75, position 166 

有人可以告诉我如何增加文本配额?正如你所看到的,我将它设置为最大整数大小。

编辑

蒂姆的建议后,这里是我的新Web.Config文件:

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="6553600" maxBufferPoolSize="5242880" maxReceivedMessageSize="6553600" 
     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/WebServices/NavigationService.svc/" 
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INavigationService" 
    contract="NavigationService.INavigationService" name="BasicHttpBinding_INavigationService" /> 
</client> 
<services> 
    <service name="Navigation.INavigationService"> 

    <endpoint address="" 
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_INavigationService" 
       contract="NavigationService.INavigationService" /> 

    </service> 
</services> 

+0

发表您的服务配置文件 - 它看起来像你需要增加值在那里,不是你的客户端上。 – Tim

+0

你正在显示客户端的配置,你的服务器端是否也有maxBuffer,contentLength,messageSize等相同的配置? – loopedcode

+0

伙计们,我的服务和我的客户端都在相同的IIS应用程序下运行,所以web.config对于两者都是相同的。 – Icemanind

回答

1

基于错误的信息和你的问题的描述,您需要确保您的服务具有相同的设置,请参阅相同的bindingConfigendpoint元素的定义绑定:

<system.serviceModel> 
    <services> 
    <service name="Navigation.INavigationService"> 
     <endpoint address="" 
       binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_INavigationService" 
       contract="NavigationService.INavigationService" /> 
    </service> 
    </services> 
</system.serviceModel> 

如果你使用.NET 4.0,并没有指定的服务元素,那么你使用的是默认的终结点和默认绑定(这意味着你的仅限于8192 maxStringContentLength)。解决此问题的最简单方法是从配置的绑定部分中删除name属性 - 然后,.NET将使用您的定义作为默认绑定。例如:

<binding closeTimeout="00:01:00" .... 

注意没有name属性设置。

您可能需要使用选项1在这种情况下,或创建一个类似的绑定定义没有名字,因为我不是100%肯定默认绑定用于客户端;他们肯定是为了这项服务。

上默认绑定和端点的更多信息,请参见A Developer's Introduction to Windows Communication Foundation 4

基于编辑

附加应答试试这个:

<client> 
    <endpoint address="http://localhost/WebServices/NavigationService.svc/" 
      binding="basicHttpBinding" 
      contract="NavigationService.INavigationService" 
      name="BasicHttpBinding_INavigationService" /> 
</client> 

删除<services>部分作为默认端点机制的WCF 4.0将处理为你,从删除bindingConfiguration属性客户端端点。

+0

我删除了名称标签并添加了标签。我需要在某处指定最大尺寸吗? – Icemanind

+0

只要绑定(没有名称属性)具有更大的大小定义,你应该没问题。 – Tim

+0

呃!同样的确切错误。你有什么建议蒂姆? – Icemanind

相关问题