【问题标题】:F# Type Provider for WSDL and BasicHttpBinding用于 WSDL 和 BasicHttpBinding 的 F# 类型提供程序
【发布时间】:2012-10-28 15:05:20
【问题描述】:

当我在 C# 中使用 WSDL 服务时,我能够将两个参数传递给构造函数; BasicHttpBinding 和 EndpointAddress

BasicHttpBinding basicHttpBinding = new BasicHttpBinding { MaxReceivedMessageSize = 20000000, MaxBufferSize = 20000000 };
EndpointAddress endpointAddress = new EndpointAddress(delarsListUrl);
var ds = new DealersService.DealersServiceClient(basicHttpBinding,endpointAddress);

当我在 F# 中使用 WSDL 类型提供程序时,我只能调用不带任何参数或带有 BasicHttpBinding 类型参数的构造函数。那么如何设置 MaxReceivedMessageSize 或 MaxBufferSize 等参数呢?

编辑:

如果我把它放到 Azure Worker 角色的 app.config 中

<system.serviceModel>
   <bindings>
     <basicHttpBinding>
       <binding name="basicHttp" allowCookies="true"
             maxReceivedMessageSize="20000000"
             maxBufferSize="20000000"
             maxBufferPoolSize="20000000">
         <readerQuotas maxDepth="32"
           maxArrayLength="200000000"
           maxStringContentLength="200000000"/>
       </binding>
     </basicHttpBinding>
   </bindings>
 </system.serviceModel>

它没有帮助,我仍然收到 maxReceivedMessageSize 只有 64k 的异常,我应该更改它。我在 C# 中遇到了同样的问题,app.config 设置似乎被忽略了,所以我通过将带有这些设置的 BasicHttpBinding 传递给构造函数来解决它。

【问题讨论】:

  • 来自MSDN: "有两种方法可以为 WSDL 连接指定配置设置,使用项目的 app.config 文件,或者使用类型提供程序声明中的静态类型参数”。我猜 app.config 方法更灵活,因为当有多个应用程序使用同一个 F# 库时,您可能需要单独配置它们。 Azure 似乎也不是 app.config 的障碍。
  • @bytebuster 我编辑了我的帖子。 app.config 中的设置似乎没有被使用

标签: web-services f# wsdl type-providers


【解决方案1】:

简化的数据上下文(通过 T.GetDataContext() 创建)仅公开无参数构造函数和接受 EndpointAddress 的构造函数。如果您想手动设置绑定 - 您可以直接实例化客户端类(它应该位于 ServiceTypes 中),即:

type WSDL = Microsoft.FSharp.Data.TypeProviders.WsdlService< @"http://www.webservicex.net/RealTimeMarketData.asmx?WSDL">
let client = new WSDL.ServiceTypes.RealTimeMarketDataSoapClient(...)

【讨论】:

  • 对于任何好奇的人,这个解决方案中的“...”类似于:new BasicHttpBinding(MaxReceivedMessageSize = 200000L), new EndpointAddress(address)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多