【发布时间】:2015-09-15 20:33:30
【问题描述】:
这个问题可能已经有了答案,但没有一个对我有用。我对 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?
WCF Error - The maximum message size quota for incoming messages (65536) has been exceeded
我创建了一个项目并在本地机器上成功运行。当我在 IIS 上发布它并在 Windows 窗体应用程序下运行它时,我收到此错误:
已超出传入邮件的最大邮件大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。
这是我的服务器 (WCF) web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="connectionString" value="data source=localhost; initial catalog=TWO; integrated security=SSPI"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<pages validateRequest="false" />
<httpRuntime requestValidationMode="2.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Service1.IService1">
<endpoint
address=""
binding="basicHttpBinding"
contract="Service1.IService1">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:50935/Service1.svc"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding
maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="behaviorGPLineItemsService">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
这是我的客户(Winforms)app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="2147483647"/>
</system.web>
<system.serviceModel>
<client>
<endpoint address="http://192.168.0.60/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="GPLineItemsService.IService1"
name="BasicHttpBinding_IService1" />
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="GpWebServiceBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
这是我用来调用服务的客户端代码。
EndpointAddress address = new EndpointAddress(GPWCFEndPointAddress);
BasicHttpBinding binding = new BasicHttpBinding();
GPLineItemsService.Service1Client gpService = new GPLineItemsService.Service1Client(binding, address);
GPLineItemsService.GPItems gpItems = new GPLineItemsService.GPItems();
gpItems = gpService.InsertUpdateLineItemsInGP(dtGPItems);
opResult = gpItems.ErrorGPItems;
您的所有帮助将不胜感激。谢谢。
【问题讨论】:
-
这是我尝试的第一个答案。不幸的是没有工作。 :-(
-
@GrantWinney:谢谢,我已经尝试过,并更新了问题中的客户端 app.config。它没有工作。 :-(
-
您要传输的数据有多大?
-
@DavidG 大约 300~500kb。谢谢。