0
votes

I am at a loss... not sure exactly why this is happening. I have gone through at least 50 pages in Google and scoured StackOverflow for this answer. When I run this code I keep getting the error message:

"There was a an error while trying to deserialize parameter http://tempuri.org/:message. The InnerException message was 'There was an error deserializing the object of type Application.Interfaces.Mail.MailMessage. 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.'"

Here is what I have on the WCF service (server):

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

And what I have on the client side:

<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>
1
Have you tried to set up the binding in code (rather than in the app.config file)? I have a working setup for NetTcpBinding, but I see you want to use BasicHttpBinding so I'd rather not paste it here.Alan
No, I haven't tried it using code. What difference does it make if I bind it in code vs config?Josh Barker
Theoretically, nothing. However, I did have to fight to make things work with net.tcp and there was one case in which I had to resort to a code-based solution on the client side (see geekswithblogs.net/RandyMichak/archive/2009/03/04/…)Alan
You answer should answer the question; this is not helpful. -1.Michael Hedgpeth

1 Answers

0
votes

Not 100% sure if that's the problem - but you definitely have some fishy thing going on with your addresses....

In your server config you have:

<baseAddresses>
     <add baseAddress="http://myapp.com/"/>
 </baseAddresses>

and

  <endpoint bindingConfiguration="BasicHttpBinding_IMailer" 
            bindingName="BasicHttpBinding_IMailer" binding="basicHttpBinding" 
            address="http://myapp.com/" 
            contract="Application.Services.Local.Mail.IEmailer">

yet in your client side config, you use

<client>
    <endpoint address="http://myapp.com/Mail/Mailer.svc"  ... />
</client>

So what is your address, really? If you're hosting your WCF service in IIS, I don't think you even need anything in your server-side config - neither a <baseAddresses> nor the address= on the endpoint will really have much say in what the service address looks like - it will be determined by your server name and name of the virtual directory and the name and extension of that *.svc file contained in it.

But these misleading addresses could lead to a misconfiguration, so that your real, actual endpoint doesn't get any custom setting, but will use the default settings instead....

Try to clean up your server side config - does that help at all??