【发布时间】: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