Asif
Asif

Reputation: 184

The maximum message size quota for incoming messages (65536) has been exceeded WCF

    <?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name ="SaadiqinWcf.SaadiqinServiceBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name ="jsonBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <services>
      <service name="SaadiqinWcf.SaadiqinService" behaviorConfiguration="SaadiqinWcf.SaadiqinServiceBehavior">
        <endpoint name ="SaadiqinEndPoint" address="**" binding="basicHttpBinding" bindingConfiguration="myBindingConfiguration" contract="**"  />
        <!-- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>--> 
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="myBindingConfiguration" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00">
          <readerQuotas maxDepth="128" maxStringContentLength="8388608"
            maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding> 
    </bindings>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <httpProtocol>
      <customHeaders>
        <add name ="Access-Control-Allow-Origin" value ="*"/>
      </customHeaders>
    </httpProtocol>
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <connectionStrings>
    <add name="SaadiqinEntities" connectionString="data source=*****,***;initial catalog=***;persist security info=true;user id=***; Password=***; TrustServerCertificate=True; multipleactiveresultsets=True;application name=EntityFramework" />
  </connectionStrings>    
</configuration>

This is my Web.config file. I got the error in WCF while running the test client. I added the binding configuration also, but it still throwing the same error ( 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.).

I am already setting the MaxReceivedMessageSize property in my web.config to a large value , I also used the above config to set the binding in the code of the client itself as well as the service but no change.

Is the binding correct? Do I need to add something else or I need to remove something. I am confused.

Note: I am testing the service from WCF Test client.

Upvotes: 0

Views: 480

Answers (1)

Asif
Asif

Reputation: 184

I found the answer. Actually the WCF Test Client has its own configuration. I changed the config file. Now working like a charm. :)

Thanks

Upvotes: 1

Related Questions