超出配额最大邮件大小(默认为65536)

时间:2014-06-22 10:24:02

标签: c# wcf

每次超出最大配额大小时我都会得到,并且我必须使用MaxReceivedMessageSize来增加它,因为你知道默认情况下是65536字节。

在我的web.config中,我认为当我增加该属性时它是正确的,但我不知道为什么我收到该错误消息。

我正在阅读stackoverflow中的类似错误,我正在测试这些示例,但我没有得到解决方案。

如果我没有超出65536字节,wcf正在工作。

我的web.config是:

<configuration>
  <appSettings>
    <add key="connection" value="Server=localhost;Port=3306;Database=david;Uid=root;Pwd=root;"/>
    <add key="uploads" value="C:\Users\DMR\Google Drive\DESARROLLO\PHP\android\contents\img\uploads\"/>
  </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 个答案:

答案 0 :(得分:0)

好吧,

今天早上打架后我必须配置WCF,我已经在web.config中使用此配置和客户端更改了客户端测试WCF:

enter image description here

我在下一个链接中得到了这个解决方案,非常明确: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 
    \Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
  <appSettings>
    <add key="connection" value="Server=localhost;Port=3306;Database=david;Uid=root;Pwd=root;" />
    <add key="uploads" value="C:\Users\DMR\Google Drive\DESARROLLO\PHP\android\contents\img\uploads\" />
  </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>