我有一个WCF服务,从数据库返回1000条记录到客户端。我有一个ASP。NET WCF客户端(我已经在asp.net web应用程序项目中添加了服务引用来使用WCF)。
当我运行客户端应用程序时,我得到以下消息:
传入消息的最大消息大小配额(65536)已为 超过了。如果需要增加配额,使用 MaxReceivedMessageSize属性 适当的绑定元素。
任何帮助吗?如何增加消息大小配额?
我有一个WCF服务,从数据库返回1000条记录到客户端。我有一个ASP。NET WCF客户端(我已经在asp.net web应用程序项目中添加了服务引用来使用WCF)。
当我运行客户端应用程序时,我得到以下消息:
传入消息的最大消息大小配额(65536)已为 超过了。如果需要增加配额,使用 MaxReceivedMessageSize属性 适当的绑定元素。
任何帮助吗?如何增加消息大小配额?
当前回答
我解决了问题…如下
<bindings>
<netTcpBinding>
<binding name="ECMSBindingConfig" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" portSharingEnabled="true">
<readerQuotas maxArrayLength="2147483647" maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" maxDepth="2147483647"
maxBytesPerRead="2147483647" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ECMSServiceBehavior">
<dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483647" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceTimeouts transactionTimeout="00:10:00" />
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="100"
maxConcurrentInstances="100" />
</behavior>
</serviceBehaviors>
</behaviors>
其他回答
当我在web.config上使用这个设置时,我得到了这个错误
System.ServiceModel.ServiceActivationException
我像这样设置设置:
<service name="idst.Controllers.wcf.Service_Talks">
<endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_TalksAspNetAjaxBehavior"
binding="webHttpBinding" contract="idst.Controllers.wcf.Service_Talks" />
</service>
<service name="idst.Controllers.wcf.Service_Project">
<endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_ProjectAspNetAjaxBehavior"
binding="basicHttpBinding" bindingConfiguration="" bindingName="largBasicHttp"
contract="idst.Controllers.wcf.Service_Project" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="largBasicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_Username" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding_Username"
contract="Exchange.Exweb.ExchangeServices.ExchangeServicesGenericProxy.ExchangeServicesType"
name="ServicesFacadeEndpoint" />
</client>
如果你正在动态创建你的WCF绑定,下面是使用的代码:
BasicHttpBinding httpBinding = new BasicHttpBinding();
httpBinding.MaxReceivedMessageSize = Int32.MaxValue;
httpBinding.MaxBufferSize = Int32.MaxValue;
// Commented next statement since it is not required
// httpBinding.MaxBufferPoolSize = Int32.MaxValue;
我解决了我的问题在必应地图WPF在我的项目使用CalculateRoute()。 在我的案例中的解决方案是设置maxReceivedMessageSize和maxReceivedMessageSize属性“httpTransport”为“customBinding”部分。
我设置了应用程序。配置文件。配置myApp.config)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IGeocodeService" />
<binding name="BasicHttpBinding_IRouteService" />
</basicHttpBinding>
<customBinding>
<binding name="CustomBinding_IGeocodeService">
<binaryMessageEncoding />
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
<binding name="CustomBinding_IRouteService">
<binaryMessageEncoding />
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
contract="BingServices.IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/binaryHttp"
binding="customBinding" bindingConfiguration="CustomBinding_IGeocodeService"
contract="BingServices.IGeocodeService" name="CustomBinding_IGeocodeService" />
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRouteService"
contract="BingServices.IRouteService" name="BasicHttpBinding_IRouteService" />
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/binaryHttp"
binding="customBinding" bindingConfiguration="CustomBinding_IRouteService"
contract="BingServices.IRouteService" name="CustomBinding_IRouteService" />
</client>
</system.serviceModel>
我找到了简单的方法
右键单击webconfig或app配置文件,然后单击EDIT WCF CONFIGURATION,然后进入bingdigs并选择您的服务和权限 边显示maxReciveMessageSize给出一个大的数字——