我在这段代码中使用 F# 和 WsdlTypeProvider:
type svc = FSharp.Data.TypeProviders.WsdlService<"http://my.service.url?wsdl">
let svcClient = svc.GetServicePort()
在大多数情况下,它在客户端调用某些方法时工作得很好。但在某些情况下,我会收到此消息:
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.
除了绑定(bind)上没有这样的属性。可以使用以下方式访问绑定(bind):
let binding = svcClient.DataContext.Endpoint.Binding
将绑定(bind)转换为具有该属性的 BasicHttpBinding 也不起作用,因为显然绑定(bind)与继承无关:
let binding = svcClient.DataContext.Endpoint.Binding :?> System.ServiceModel.BasicHttpBinding
它会导致这个错误:
Unable to cast object of type 'System.ServiceModel.Channels.CustomBinding' to type 'System.ServiceModel.BasicHttpBinding'.
所以问题是: 如何在使用 WsdlTypeProvider 时增加 MaxReceivedMessageSize?
我的 App.Config 中似乎没有任何设置,就像我通过生成代理等以常规方式附加到服务时一样。
最佳答案
如果您出于测试目的编写此代码,则可以使用 BasicHttp 绑定(bind),但为了支持 session ,并且出于安全原因,您不应将 BasicHttp 用于应用程序的商业用途。寻找 netTcp 或 WsHttp 绑定(bind)。以下代码适用于 netTcp 绑定(bind)。
<bindings>
<customBinding>
<binding name="CustomBinding_MyService">
<binaryMessageEncoding>
<readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000"/>
</binaryMessageEncoding>
<tcpTransport maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000" maxBufferSize="200000000">
<extendedProtectionPolicy policyEnforcement="Never"/>
</tcpTransport>
</binding>
</customBinding>
</bindings>
希望这对您有所帮助!
关于web-services - F# WsdlTypeProvider MaxReceivedMessageSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49173682/
相关文章:
php - 如何使用 discord API 从用户名获取 discord 用户 ID
javascript - 如何让 chrome.webRequest 等待 XMLHttpReque
apache - Microsoft Edge localhost apache NTLM 始终尝试
git - 致命的 : protocol error: bad line length charac
python - 如何使用pymongo在mongodb中创建索引
python - 如何在 Linux 上的 Python 中检查文件锁?
spring-security - Spring Security OAuth2 资源服务器重试/弹
javascript - i18next-json-sync 使用问题