【问题标题】:F# WsdlTypeProvider MaxReceivedMessageSizeF# WsdlTypeProvider MaxReceivedMessageSize
【发布时间】:2018-03-08 12:58:31
【问题描述】:

我正在使用 F# 和带有此代码的 WsdlTypeProvider:

type svc = FSharp.Data.TypeProviders.WsdlService<"http://my.service.url?wsdl">
let svcClient = svc.GetServicePort()

在大多数情况下,它在客户端调用某些方法时效果很好。但在某些情况下,我会收到以下消息:

已超出传入邮件的最大邮件大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。

除非绑定上没有这样的属性。可以使用以下方式访问绑定:

let binding = svcClient.DataContext.Endpoint.Binding

将绑定转换为具有该属性的 BasicHttpBinding 也不起作用,因为显然绑定与继承无关:

let binding = svcClient.DataContext.Endpoint.Binding :?> System.ServiceModel.BasicHttpBinding

它会导致这个错误:

无法转换类型的对象 'System.ServiceModel.Channels.CustomBinding' 键入 'System.ServiceModel.BasicHttpBinding'。

所以问题是: 如何在使用 WsdlTypeProvider 时增加 MaxReceivedMessageSize?

我的 App.Config 中似乎没有任何设置,就像我通过生成代理等以常规方式附加到服务一样。

【问题讨论】:

标签: web-services wcf f# f#-data


【解决方案1】:

如果您编写此代码是为了测试目的,则可以使用 BasicHttp 绑定,但为了支持会话以及出于安全原因,您不应将 BasicHttp 用于应用程序的商业用途。使用 netTcp 或 WsHttp 绑定。以下代码适用于 netTcp 绑定。

<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>

希望这会有所帮助!

【讨论】:

  • 您好,由于我使用的是 TypeProvider,因此我无法控制服务的连接方式。此外,我无法控制服务(可以这么说,这超出了我的管辖范围)。所以我不确定如何使用您的答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-13
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 2013-02-06
相关资源
最近更新 更多