简体   繁体   中英

Configuration of a Wcf Service: Web.config maxReceivedMessageSize not working (Even with edit wcf Configuration)

To easy reproduce the error I have created a new wcf service called TestService.

When I do a loop of 9999 times I get the desired message: The maximum message size quota for incoming messages (65536) has been exceeded.

So I change the required things described on other stackoverflow treads. but without succes... then I found this manual ( http://keithelder.net/2008/01/17/exposing-a-wcf-service-with-multiple-bindings-and-endpoints/ ) using the tool Wcf Service Configurator. but same error.

Here is the Config:

<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttp" maxBufferPoolSize="9999999" maxBufferSize="9999999"
      maxReceivedMessageSize="9999999" />
  </basicHttpBinding>
</bindings>
<services>
  <service name="TestService.Service1">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttp"
      name="BasicHttp" contract="TestService.IService1" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="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="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

If you want the code. I'm happy to share it. it's only a loop filling a list of strings though.

Edit: I've added to a new service so I can have a client config. Problem remains.

<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
  <service name="TestService2.Service1">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttp"
      name="BasicHttp" contract="TestService2.IService1"  />
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttp" maxBufferSize="65536999" maxReceivedMessageSize="65536999">
      <readerQuotas maxStringContentLength="65536999" maxArrayLength="65536999" />
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost:58526/Service1.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttp" contract="ServiceReference1.IService1"
    name="BasicHttp" />
</client>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="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="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>  
</configuration>

You must ensure that both, client and server configuration files has the appropriate values, like this: For server side (binding without name):

<basicHttpBinding>
        <binding 
                 maxReceivedMessageSize="20000000" 
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
            <readerQuotas maxDepth="1024" 
                 maxArrayLength="200000000"
                 maxStringContentLength="200000000"/>
        </binding>
    </basicHttpBinding>

And also this for behavior:

<behaviors>
  <serviceBehaviors>
    <behavior name="ECMSServiceBehavior">
      <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
</behavior>
  </serviceBehaviors>
</behaviors>

For client side:

<basicHttpBinding>
        <binding 
                 maxReceivedMessageSize="20000000" 
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
            <readerQuotas maxDepth="1024" 
                 maxArrayLength="200000000"
                 maxStringContentLength="200000000"/>
        </binding>
    </basicHttpBinding>

Hope it helps.

Issue exists in client config. Check client configuration. Server side configuration seems to be fine.

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