我很茫然......不确定为什么会发生这种情况。我已经在Google中浏览了至少50页,并搜索了StackOverflow以获得此答案。当我运行此代码时,我不断收到错误消息:
“尝试反序列化参数http://tempuri.org/:message时发生错误.InstallException消息是'反序列化Application.Interfaces.Mail.MailMessage类型的对象时出错。最大字符串内容长度配额(8192)读取XML数据时已超出。可以通过更改创建XML读取器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性来增加此配额。“
以下是我在WCF服务(服务器)上的内容:
<system.serviceModel>
<services>
<service behaviorConfiguration="SimpleServiceBehavior" name="Application.Services.Mail.Mailer">
<host>
<baseAddresses>
<add baseAddress="http://myapp.com/"/>
</baseAddresses>
</host>
<endpoint bindingConfiguration="BasicHttpBinding_IMailer" bindingName="BasicHttpBinding_IMailer" binding="basicHttpBinding" address="http://myapp.com/" contract="Application.Services.Local.Mail.IEmailer">
<identity>
<dns value="myapp.com"/>
</identity>
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMailer" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="800000" maxBufferPoolSize="800000" maxReceivedMessageSize="800000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="800000" maxStringContentLength="800000" maxArrayLength="800000" maxBytesPerRead="800000" maxNameTableCharCount="800000" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
我在客户端拥有的东西:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMailer" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880" messageEncoding="Text" 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>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myapp.com/Mail/Mailer.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMailer" contract="Interfaces.Mail.IEmailer" name="BasicHttpBinding_IMailer"/>
</client>
</system.serviceModel>
答案 0 :(得分:0)
不是100%确定这是否是问题 - 但你的地址肯定会有一些可疑的事情......
在您的服务器配置中,您有:
<baseAddresses>
<add baseAddress="http://myapp.com/"/>
</baseAddresses>
和
<endpoint bindingConfiguration="BasicHttpBinding_IMailer"
bindingName="BasicHttpBinding_IMailer" binding="basicHttpBinding"
address="http://myapp.com/"
contract="Application.Services.Local.Mail.IEmailer">
在您的客户端配置中,您使用
<client>
<endpoint address="http://myapp.com/Mail/Mailer.svc" ... />
</client>
那你的地址到底是什么?如果您在IIS中托管WCF服务,我认为您甚至不需要服务器端配置中的任何内容 - 端点上的<baseAddresses>
和address=
都不会有太多发言权服务地址是什么样的 - 它将取决于您的服务器名称和虚拟目录的名称以及其中包含的* .svc文件的名称和扩展名。
但是这些误导性的地址可能会导致配置错误,因此您的真实实际端点不会获得任何自定义设置,但会使用默认设置....
尝试清理服务器端配置 - 这有帮助吗?