简体   繁体   中英

Assign a custom binding configuration for wsHttpBinding

I'm running into some issues with what I believe is a pretty simple problem.

When trying to send "large" messages over WCF, I am getting the error:

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

To remedy this, I created a custom binding configuration with a higher value for MaxReceivedMessageSize. But I still get the error, as if the value is not being read.

Here is my Server App.config:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="largeBinding" maxReceivedMessageSize="2147483647">
          <readerQuotas maxArrayLength="2147483647"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="EMS.Services.TradeController">
       <endpoint address="http://localhost:9002/TradeService"
                  binding="wsHttpBinding"
                  bindingConfiguration="largeBinding"
                  contract="EMS.Contracts.Services.ITradeService"/>
      </service>
    </services>
  </system.serviceModel>

And here is my Client App.config:

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="largeBinding" maxReceivedMessageSize="2147483647">
      <readerQuotas maxArrayLength="2147483647"/>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost:9002/TradeService"
            binding="wsHttpBinding"
            bindingConfiguration="largeBinding"
            contract="EMS.Contracts.Services.ITradeService"/>
</client>

Is there a part I am missing to assign the binding properly?

Is the client's configuration automatically generated by Adding Service Reference tool? I suspect whether the client proxy uses the service endpoint created by Wshttpbinding . There seems nothing with your current configuration.
Besides, please consider configuring other attributes.

     <wsHttpBinding>
        <binding name="largeBinding" allowCookies="true"
 maxReceivedMessageSize="20000000"
 maxBufferSize="20000000"
 maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32"
 maxArrayLength="200000000"
 maxStringContentLength="200000000"/>
        </binding>
      </wsHttpBinding>

The MaxBufferSize and ReaderQuotas property also needs to be configured.
MaxBufferSize
ReaderQuotas
Feel free to let me know if the problem still exists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM