Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This has been frustrating me for ages!

I have a WCF service in my web app.

I have a test that sends a large amount of data to it in a single request (about 2500 Bytes of 'person' details from my random name generator)

I get slapped with
The remote server returned an error: (413) Request Entity Too Large.

Ok - I get that it's pretty big. So I changed my binding settings:

web.config:
HTML
<system.serviceModel>
    <services>
      <service name="fw.Services.AServiceAccess">
        <host>
          <baseAddresses>
            <add baseAddress="https://www.fw.codep.co.uk/Services/AServiceAccess.svc" />
          </baseAddresses>
        </host>
        <endpoint address="" binding="mexHttpsBinding" contract="fw.Services.IAServiceAccess">
          <identity>
            <dns value="www.fw.codep.co.uk" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <basicHttpsBinding>
        <binding name="mexHttpsBinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpsBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>


and even the app.config of my unit test project:
XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="MetadataExchangeHttpsBinding_IAServiceAccess" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://www.fw.codep.co.uk/Services/AServiceAccess.svc"
          binding="wsHttpBinding" bindingConfiguration="MetadataExchangeHttpsBinding_IAServiceAccess"
          contract="AServiceAccessService.IAServiceAccess"
          name="MetadataExchangeHttpsBinding_IAServiceAccess">
        <identity>
          <dns value="www.fw.codep.co.uk" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>



Still same error >_<<br mode="hold" />
What's going wrong?


Thanks
Andy
Posted
Comments
virusstorm 21-May-15 12:30pm    
How did you calculate your message size?
Andy Lanng 21-May-15 13:05pm    
Correctly :P
I Streamed it to a memory buffer and returned a byte[]. I found the code online. It's consistently about 2.5 kb give or take 200 bytes.
The object has a few strings and a list of 256 person records. Person records contain 7 strings (fairly short being name,email etc) and 2 dates.
virusstorm 21-May-15 15:34pm    
What exactly did you stream into a memory buffer? Your data is sent in UTF-8 XML to the server. The XML and associated white space counts towards the size of the message. If you use a tool like Fiddler, you can capture the details of the message and inspect its true size. You will find that you are going to simply have to increase your buffer sizes.
Andy Lanng 22-May-15 4:22am    
hmm - this is my byte calc code:

private byte[] ToByteArray(object source)
{
var formatter = new BinaryFormatter();
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, source);
return stream.ToArray();
}
}

fidler didn't see any traffic at all >_<
virusstorm 22-May-15 13:25pm    
I see you have an HTTPS address, did you enable Fiddler to capture SSL traffic?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900