Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF service maxReceivedMessageSize basicHttpBinding issue

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> 
like image 228
BlargleMonster Avatar asked Jun 17 '12 02:06

BlargleMonster


People also ask

What is the default MaxReceivedMessageSize for WCF service?

By default, it is 65536.

What is the maximum value for MaxReceivedMessageSize?

I noticed that 2147483647 seems to be a popular choice for maxReceivedMessageSize but is this the limit?

How do you increase MaxReceivedMessageSize?

To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

What is BasicHttpBinding?

BasicHttpBinding is suitable for communicating with ASP.NET Web Service (ASMX) based services that conform to the WS-Basic Profile that conforms with Web Services. This binding uses HTTP as the transport and text/XML as the default message encoding. Security is disabled by default.


2 Answers

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

like image 128
TRayburn Avatar answered Oct 02 '22 15:10

TRayburn


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> 
like image 35
Serj Sagan Avatar answered Oct 02 '22 17:10

Serj Sagan