36

I can't seem to get my WCF service to accept large amounts of data being sent up to it.

I configured the maxReceivedMessageSize for the client and could receive large data down just fine, that's not the issue. It's sending data up to the service.

I tried to configure the service but haven't had any luck. Here's my web.config:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceDiscovery />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Service.IService">
        <clear />
        <endpoint binding="basicHttpBinding" bindingConfiguration="MessageSizeBasic" contract="Service.IService" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="MessageSizeBasic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="MessageSizeWeb" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
      </webHttpBinding>
    </bindings>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
KyleMit
  • 30,350
  • 66
  • 462
  • 664
BlargleMonster
  • 1,602
  • 2
  • 18
  • 33

3 Answers3

65

Removing the name from your binding will make it apply to all endpoints, and should produce the desired results. As so:

<services>
  <service name="Service.IService">
    <clear />
    <endpoint binding="basicHttpBinding" contract="Service.IService" />
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
        maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </basicHttpBinding>
  <webHttpBinding>
    <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
  </webHttpBinding>
</bindings>

Also note that I removed the bindingConfiguration attribute from the endpoint node. Otherwise you would get an exception.

This same solution was found here : Problem with large requests in WCF

Community
  • 1
  • 1
TRayburn
  • 1,535
  • 12
  • 10
  • 1
    Thank you very much. As a note I also had to remove the bindingConfiguration attribute from my endpoint since it referenced a name I took out. – BlargleMonster Jun 17 '12 at 03:26
  • What else do I need to do in addition to above changes in web.config? – Arti Mar 20 '14 at 12:42
  • Please refer to this post to check my web.config file. [http://stackoverflow.com/questions/22525783/configuring-wcf-rest-web-config](stackoverflow) – Arti Mar 20 '14 at 12:43
  • 1
    I've been breaking my head over this... Thank you, this made my morning. – Aage Oct 29 '14 at 07:05
1

When using HTTPS instead of ON the binding, put it IN the binding with the httpsTransport tag:

    <binding name="MyServiceBinding">
      <security defaultAlgorithmSuite="Basic256Rsa15" 
                authenticationMode="MutualCertificate" requireDerivedKeys="true" 
                securityHeaderLayout="Lax" includeTimestamp="true" 
                messageProtectionOrder="SignBeforeEncrypt" 
                messageSecurityVersion="WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10"
                requireSignatureConfirmation="false">
        <localClientSettings detectReplays="true" />
        <localServiceSettings detectReplays="true" />
        <secureConversationBootstrap keyEntropyMode="CombinedEntropy" />
      </security>
      <textMessageEncoding messageVersion="Soap11WSAddressing10">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
                      maxArrayLength="2147483647" maxBytesPerRead="4096" 
                      maxNameTableCharCount="16384"/>
      </textMessageEncoding>
      <httpsTransport maxReceivedMessageSize="2147483647" 
                      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
                      requireClientCertificate="false" />
    </binding>
Serj Sagan
  • 28,927
  • 17
  • 154
  • 183
0

Is the name of your service class really IService (on the Service namespace)? What you probably had originally was a mismatch in the name of the service class in the name attribute of the <service> element.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • My service interface really is IService at the moment. I may change it later but for now it's a bit of a singleton in my system. – BlargleMonster Jun 17 '12 at 04:38
  • 1
    The service *interface*, or the service **class**? The value of the `name` attribute for the `` element must be the name of the service **class**. – carlosfigueira Jun 17 '12 at 05:48
  • I tried that options and it's another possible solution. I'm not sure why the Service Configuration Editor tool only let me pick the interface when managing my service but I'm glad to know another way to fix it if I need to use names again. – BlargleMonster Jun 18 '12 at 03:10
  • I am using WCF rest online 40 template. What should be the service name? – Arti Mar 20 '14 at 12:45