Nat*_*ate 592
您需要这样的东西来增加App.config或Web.config文件中的邮件大小配额:
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
并在端点配置中使用绑定名称,例如
...
bindingConfiguration="basicHttp"
...
Run Code Online (Sandbox Code Playgroud)
值的理由很简单,它们足够大以容纳大多数消息.您可以调整该数字以满足您的需求.低默认值基本上是为了防止DOS类型的攻击.使其成为20000000将允许分布式DOS攻击有效,默认大小为64k将需要大量客户端来支持大多数服务器.
Mic*_*ues 148
如果您在使用WCF测试客户端时仍然收到此错误消息,那是因为客户端具有单独的MaxBufferSize设置.
要纠正此问题:
将显示可编辑设置列表,包括MaxBufferSize.
注意: 默认情况下,自动生成的代理客户端还将MaxBufferSize设置为65536.
Bha*_*h K 98
如果要动态创建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;
Run Code Online (Sandbox Code Playgroud)
小智 44
在WCF测试客户端有它自己的客户端配置.
运行测试客户端并滚动到底部.如果双击"配置文件"节点,您将看到XML表示.正如你所看到的maxReceivedMessageSize是65536.
要编辑它,请右键单击"配置文件"树节点,然后选择"编辑方式" SvcConfigEditor.编辑器打开时展开Bindings并双击自动生成的绑定.
您可以在此处编辑所有属性,包括maxReceivedMessageSize.完成后,单击文件 - 保存.
最后,当您返回WCF测试客户端窗口时,单击工具 - 选项.
注意:取消选中启动服务时始终重新生成配置.
小智 23
我找到了简单的方法
---右键单击webconfig或app配置文件,然后单击EDIT WCF CONFIGURATION并选择bingdigs和选择yore服务,右侧显示maxReciveMessageSize给出一个大数字---
我解决了这个问题......如下
<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>
Run Code Online (Sandbox Code Playgroud)
小智 8
我在我的项目中使用CalculateRoute()在Bing Maps WPF上解决了我的问题.我的解决方案是在"customBinding"部分的属性"httpTransport"上设置maxReceivedMessageSize和maxReceivedMessageSize.
我在applications.config文件(es.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>
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)
根据我的经验,另一个需要考虑的重要事项..
我强烈建议不要最大化 maxBufferPoolSize,因为在应用程序域(即应用程序池)回收之前,池中的缓冲区永远不会被释放。
一段时间的高流量可能会导致大量内存被使用而永远不会释放。
更多细节在这里:
对于HTTP:
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="200"
maxArrayLength="200000000"
maxBytesPerRead="4096"
maxStringContentLength="200000000"
maxNameTableCharCount="16384"/>
</binding>
</basicHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
对于TCP:
<bindings>
<netTcpBinding>
<binding name="tcpBinding"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="200"
maxArrayLength="200000000"
maxStringContentLength="200000000"
maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
</binding>
</netTcpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
重要:
如果您尝试传递具有许多连接对象的复杂对象(例如:树数据结构,具有许多对象的列表...),则无论您如何增加配额,通信都会失败。在这种情况下,必须增加包含对象的数量:
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
...
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
405112 次 |
| 最近记录: |