Превышен максимальный размер сообщения квоты (по умолчанию 65536)

#c# #wcf

#c# #wcf

Вопрос:

Я получаю каждый раз, когда превышаю максимальный размер квоты, и мне приходится использовать maxReceivedMessageSize, чтобы увеличить его, потому что, как вы знаете, по умолчанию 65536 байт.

В моем web.config я думаю, что это правильно, когда я увеличиваю это свойство, но я не знаю, почему я получаю это сообщение об ошибке.

Я читал похожие ошибки здесь, в stackoverflow, и я тестировал эти примеры, но я не получил решения.

wcf работает, если я не превысил 65536 байт.

Мой web.config:

 <configuration>
  <appSettings>
    <add key="connection" value="Server=localhost;Port=3306;Database=david;Uid=root;Pwd=root;"/>
    <add key="uploads" value="C:UsersDMRGoogle DriveDESARROLLOPHPandroidcontentsimguploads"/>
  </appSettings>

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="Android.Android">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="Android.IAndroid"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" 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>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <!-- 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"/>
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
      </serviceBehaviors>

    </behaviors>
  </system.serviceModel>
  <system.web>
    <compilation debug="true"/>
  </system.web>
</configuration>
  

Как я могу увеличить квоту до максимума?

Что не так в моем web.config

Комментарии:

1. Остальная часть кода работает, когда данные, как я уже сказал, не длиннее, чем это quoto работает нормально

2. не могли бы вы очистить и перестроить свое приложение и попробовать?

3. Дэвид, тебе нужно изменить конфигурацию как на клиенте, так и на сервере

4. Я очистил, перестроил и перезапустил IIS, в любом случае, как я могу изменить cliente? точно так же, как сервер (или служба)?

5. Микки был прав, что вы сказали, я мог настроить клиентский тестовый WCF, и он работает, теперь я установил максимальный размер int.

Ответ №1:

Ну,

после того, как сегодня утром я немного повозился с настройкой WCF, мне пришлось изменить клиентский тестовый WCF с помощью этой конфигурации и клиентской части в web.config:

введите описание изображения здесь

Я получаю это решение по следующей ссылке, оно очень четкое: http://www.lemursolution.com/node/175

Моя окончательная веб-конфигурация:

 <?xml version="1.0" encoding="UTF-8"?>
<!--
    Note: As an alternative to hand editing this file you can use the 
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in 
    machine.config.comments usually located in 
    WindowsMicrosoft.NetFrameworkv2.xConfig 
-->
<configuration>
  <appSettings>
    <add key="connection" value="Server=localhost;Port=3306;Database=david;Uid=root;Pwd=root;" />
    <add key="uploads" value="C:UsersDMRGoogle DriveDESARROLLOPHPandroidcontentsimguploads" />
  </appSettings>

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" 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>

        <binding name="BasicHttpBinding_IAndroid" maxBufferSize="2147483647"
            maxReceivedMessageSize="2147483647" />

      </basicHttpBinding>
    </bindings>

    <client>
      <endpoint address="http://dmr-pc/Android/Android.svc" binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_IAndroid" contract="IAndroid"
          name="BasicHttpBinding_IAndroid" />
    </client>

    <services>      
      <service behaviorConfiguration="ServiceBehavior" name="Android.Android">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="Android.IAndroid" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>      
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <!-- 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" />
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
        <behavior name=" MyClient">
          <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
        </behavior>
      </serviceBehaviors>

    </behaviors>
  </system.serviceModel>
  <system.web>
    <compilation debug="true" />
  </system.web>
    <system.webServer>
        <directoryBrowse enabled="false" />
    </system.webServer>
</configuration>