WCF - How to Increase Message Size Quota

后端 未结 13 2025
失恋的感觉
失恋的感觉 2020-11-22 06:16

I have a WCF Service which returns 1000 records from database to the client. I have an ASP.NET WCF client (I have added service reference in asp.net web application project

相关标签:
13条回答
  • 2020-11-22 07:08

    You'll want something like this to increase the message size quotas, in the App.config or Web.config file:

    <bindings>
        <basicHttpBinding>
            <binding name="basicHttp" allowCookies="true"
                     maxReceivedMessageSize="20000000" 
                     maxBufferSize="20000000"
                     maxBufferPoolSize="20000000">
                <readerQuotas maxDepth="32" 
                     maxArrayLength="200000000"
                     maxStringContentLength="200000000"/>
            </binding>
        </basicHttpBinding>
    </bindings>
    

    And use the binding name in your endpoint configuration e.g.

    ...
    bindingConfiguration="basicHttp"
    ...
    

    The justification for the values is simple, they are sufficiently large to accommodate most messages. You can tune that number to fit your needs. The low default value is basically there to prevent DOS type attacks. Making it 20000000 would allow for a distributed DOS attack to be effective, the default size of 64k would require a very large number of clients to overpower most servers these days.

    0 讨论(0)
  • 2020-11-22 07:08

    I solve the problem ...as follows

        <bindings>
      <netTcpBinding>
        <binding name="ECMSBindingConfig" closeTimeout="00:10:00" openTimeout="00:10:00"
          sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647" portSharingEnabled="true">
          <readerQuotas maxArrayLength="2147483647" maxNameTableCharCount="2147483647"
              maxStringContentLength="2147483647" maxDepth="2147483647"
              maxBytesPerRead="2147483647" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ECMSServiceBehavior">
          <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceTimeouts transactionTimeout="00:10:00" />
          <serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="100"
            maxConcurrentInstances="100" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    
    0 讨论(0)
  • 2020-11-22 07:11

    i got this error when using this settings on web.config

    System.ServiceModel.ServiceActivationException
    

    i set settings like this:

          <service name="idst.Controllers.wcf.Service_Talks">
        <endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_TalksAspNetAjaxBehavior"
          binding="webHttpBinding" contract="idst.Controllers.wcf.Service_Talks" />
      </service>
      <service name="idst.Controllers.wcf.Service_Project">
        <endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_ProjectAspNetAjaxBehavior"
          binding="basicHttpBinding" bindingConfiguration="" bindingName="largBasicHttp"
          contract="idst.Controllers.wcf.Service_Project" />
      </service>
    </services>
    
    <bindings>
    <basicHttpBinding>
        <binding name="largBasicHttp" allowCookies="true"
                 maxReceivedMessageSize="20000000"
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
            <readerQuotas maxDepth="32"
                 maxArrayLength="200000000"
                 maxStringContentLength="200000000"/>
        </binding>
    </basicHttpBinding>
    

    0 讨论(0)
  • 2020-11-22 07:12

    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBinding_Username" maxReceivedMessageSize="20000000"          maxBufferPoolSize="20000000">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" establishSecurityContext="false"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    
    <client>
      <endpoint
                binding="wsHttpBinding"
                bindingConfiguration="wsHttpBinding_Username"
                contract="Exchange.Exweb.ExchangeServices.ExchangeServicesGenericProxy.ExchangeServicesType"
                name="ServicesFacadeEndpoint" />
    </client>
    

    0 讨论(0)
  • 2020-11-22 07:13

    I found the easy way

    --- right click the webconfig or app config file and click EDIT WCF CONFIGURATION and got to bingdigs ans select yore service and right side show maxReciveMessageSize give a large number ---

    0 讨论(0)
  • 2020-11-22 07:14

    For me, all I had to do is add maxReceivedMessageSize="2147483647" to the client app.config. The server left untouched.

    0 讨论(0)
提交回复
热议问题