将服务部署到远程Web服务器会引发异常:'反序列化XXXX类型的对象时出错['

时间:2015-06-18 23:43:14

标签: c# wcf

我已经看到了一些关于这个问题的答案,但似乎没有一个问题符合我的情况。

我有一个本地ASP.NET MVC应用程序,它连接到WFC服务的本地开发实例。如果我向本地开发服务发送一个大字符串参数,一切都很好。当我将完全相同的服务部署到我的远程Web服务器时,我收到以下错误(其中XXXX是服务中的命名空间对象):

  

"格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://tempuri.org/:FormPost时出错。 InnerException消息是'反序列化XXXX类型的对象时出错。读取XML数据时已超出最大字符串内容长度配额(8192)。通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性,可以增加此配额。第1行,第10304位。"

这是奇怪的事情:

  1. 我本地服务(在localhost上)和远程服务(在www.MyUrl.com上)的代码库完全相同。然而,当我在他们之间切换我的客户端应用程序(在localhost上运行)时,我只得到远程服务上的错误,而不是本地错误。

  2. 当我在本地客户端上将MaxStringContentLength属性值更改为2147483647时,它没有任何区别。并且端点肯定使用正确的绑定名称。

    <binding name="BasicHttpBinding_ITheService" closeTimeout="00:01:00"
          openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          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="BasicHttpBinding_ITheService" closeTimeout="00:01:00"
          openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="01:10:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" **maxStringContentLength="2147483647"** maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
    
  3. 要更改的服务端web.config文件中没有绑定配置。它只在客户端。然而,错误是指无法反序列化作为服务端类的对象。

0 个答案:

没有答案