2017-08-08 65 views
1

我希望你能帮助我,因为我一直在撕掉我的头发与这个问题,试图从这个建议对这个问题的所有解决方案网站,也通过谷歌无济于事。其中许多人:WCF传入邮件的最大邮件大小限额(65536)已被超出

Wcf-The maximum message size quota for incoming messages (65536) has been exceeded?

WCF, The maximum message size quota for incoming messages (65536) has been exceeded

The maximum message size quota for incoming messages (65536) has been exceeded

Why do I still get "The maximum message size quota for incoming messages (65536) has been exceeded" error?

正如标题我有我的传入邮件的最大邮件大小的问题。我试图重写默认消息大小,但无论我尝试它不起作用,并且我收到的错误都倾向于指向我在App.config文件中的自定义配置,而不是使用默认设置。

我正在使用WCF服务主机/ WCF测试客户端和Visual Studio 2017专业版,我的客户端项目是更广泛的WPF MVVM项目的类库。我还没有将WCF服务复制到测试服务器2012/IIS安装中,因为这应该在我的开发环境中工作?

我正在尝试仅增加AirplaneService的最大消息大小,使所有其他服务保持默认设置。

我的客户端App.Config中,我有我的类库仅客户端:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup><system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IAirplaneService" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"> 
      <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     </binding> 
     <binding name="BasicHttpBinding_ILicenceService" /> 
     <binding name="BasicHttpBinding_ICustomerService" /> 
     <binding name="BasicHttpBinding_IMembershipService" /> 
     <binding name="BasicHttpBinding_IPrefixService" /> 
     <binding name="BasicHttpBinding_ICountryService" /> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/AirplaneService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAirplaneService" 
     contract="AirplaneService.IAirplaneService" name="BasicHttpBinding_IAirplaneService" /> 
     <endpoint address="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/LicenceService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ILicenceService" 
     contract="LicenceService.ILicenceService" name="BasicHttpBinding_ILicenceService" /> 
     <endpoint address="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/CustomerService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICustomerService" 
     contract="CustomerService.ICustomerService" name="BasicHttpBinding_ICustomerService" /> 
     <endpoint address="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/MembershipService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMembershipService" 
     contract="MembershipService.IMembershipService" name="BasicHttpBinding_IMembershipService" /> 
     <endpoint address="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/PrefixService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPrefixService" 
     contract="PrefixService.IPrefixService" name="BasicHttpBinding_IPrefixService" /> 
     <endpoint address="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/CountryService/" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICountryService" 
     contract="CountryService.ICountryService" name="BasicHttpBinding_ICountryService" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

我相信,我只需要修改客户端App.Config中,因为我不希望在接收大的消息服务方面。然而,对于完整性我也加入了相关绑定到我的服务App.Config中:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <connectionStrings> 
    <add name="FlightSchoolEntities" connectionString="metadata=res://*/FlightSchoolModel.csdl|res://*/FlightSchoolModel.ssdl|res://*/FlightSchoolModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=xx.xx.xx.xx;initial catalog=FlightSchool;persist security info=True;user id=sa;password=xxxxxxxxxxxx;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="myBasicBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"> 
      <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="Flight_School.Service.CountryService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/CountryService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" contract="Flight_School.Service.ICountryService"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     <service name="Flight_School.Service.PrefixService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/PrefixService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" contract="Flight_School.Service.IPrefixService"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      </service> 
     <service name="Flight_School.Service.MembershipService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/MembershipService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" contract="Flight_School.Service.IMembershipService"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     <service name="Flight_School.Service.CustomerService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/CustomerService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" contract="Flight_School.Service.ICustomerService"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     <service name="Flight_School.Service.LicenceService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/LicenceService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" contract="Flight_School.Service.ILicenceService"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     <service name="Flight_School.Service.AirplaneService"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/AirplaneService/" /> 
      </baseAddresses> 
     </host> 
     <!-- Service Endpoints --> 
     <!-- Unless fully qualified, address is relative to base address supplied above --> 
     <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBasicBinding" contract="Flight_School.Service.IAirplaneService"> 
      <!-- 
       Upon deployment, the following identity element should be removed or replaced to reflect the 
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
       automatically. 
      --> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <!-- Metadata Endpoints --> 
     <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
     <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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> 
    </system.serviceModel> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="mssqllocaldb" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
</configuration> 

运行此我收到以下错误:

System.ServiceModel.CommunicationException: '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.' 

的代码片段发生错误:

  using (AirplaneService.AirplaneServiceClient service = new AirplaneService.AirplaneServiceClient()) 
      { 
       List<AirplaneService.Manufacturer> manufacturers = service.GetManufacturers(); 

如果我在service-> GetManufacturers()中限制了我的结果,它将按照预期返回制造商列表。

每次我重新运行我的服务时,我需要更改WCF Test Client中的配置,但即使这样做后,运行该项目时仍会收到相同的错误。

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpBinding_IAirplaneService" sendTimeout="00:05:00" 
        maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" /> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="http://localhost:8733/Design_Time_Addresses/Flight_School.Service/AirplaneService/" 
       binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAirplaneService" 
       contract="IAirplaneService" name="BasicHttpBinding_IAirplaneService" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

您的帮助将得到最多的赞赏和许多提前感谢。

Richard。

+0

_My客户端App.Config,我在我的类库客户端only_您的配置必须在您执行的项目(Client.exe,Server.exe),而不是在库中。 – Rabban

+0

谢谢拉班,我在这里主演了这一整天必须的一切,并且显而易见的并不令人想到!我已将自定义绑定配置添加到我的.exe项目中的App.config文件,并且它按预期工作。我一定是在大约一周前将我的初始服务绑定添加到相同的App.config文件中,从而导致大脑褪色。非常感谢。 –

回答

0

将以下内容添加到您的绑定中。

<bindings> 
    <basicHttpBinding> 
    <binding name="BasicHttpBinding_IAirplaneServicer" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"> 
     <readerQuotas maxDepth="32" maxArrayLength="2147483647" maxStringContentLength="2147483647" /> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
0

感谢拉班谁指出我需要添加我的自定义绑定到.exe项目app.config文件,现在按预期工作。我必须在一个星期左右之前手动将WCF服务绑定添加到.exe项目的App.config文件中,然后在那之间和现在我忘了所有关于那个的。我也从服务项目App中删除了自定义绑定。因为这不是必需的,因为我不想发送大量数据传输到服务。非常感谢。

相关问题