WCF Service Error - Maximum message size quota for incoming messages (65536) has been exceeded

StackOverflow https://stackoverflow.com/questions/21102054

質問

All,

I have an WCF service (in asp.net 4.0 web app), running in asp.net compatibility mode. When my silverlight client posts a large chunk of data to the service Save(SomeLargeObject), I receive this message from the server (400-Bad Request). I traced the error on the server and got this from the service:

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.

To resolve the error I haved updated my server service config file (web.config):

<bindings>
      <basicHttpBinding>
        <binding name="WebStoreServices_BasicHttpBinding" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="MyBinding" maxReceivedMessageSize="2147483647" />
      </wsHttpBinding>
      <webHttpBinding>
        <binding name="NewBinding0" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
      </webHttpBinding>
    </bindings>

and my Silverlight client serivce config file:

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IWebStoreServices" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:1271/Services/WebStoreServices.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWebStoreServices"
                contract="WebStore.IWebStoreServices" name="BasicHttpBinding_IWebStoreServices" />
        </client>
    </system.serviceModel>

I still get the above error on the server, "maximum message size quota for incoming messages (65536)", it is like my binding on the server is ignored. Why is it ignoring my settings! I did use the WCF tool to create the bindings to avoid errors.

役に立ちましたか?

解決

The settings seem fine - but does the server-side endpoint using the basicHttpBinding actually reference that binding configuration with the increased MaxReceivedMessageSize setting at all??

You should have a setup something like this in your server-side web.config:

<services>
   <service name="WebStore.WebStoreServices">
       <!-- this endpoint uses basicHttpBinding and uses the binding configuration -->
       <endpoint name="basicHttp"
           address="......"
           binding="basicHttpBinding"
           bindingConfiguration="WebStoreServices_BasicHttpBinding" 
           contract="WebStore.IWebStoreServices" />
   </service>
</services>

If your basicHttpBinding endpoint is missing the bindingConfiguration="..." setting - well, then you've defined the binding configuration alright, but you're not actually using it!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top