当我在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 Type提供程序时,我只允许在没有任何参数或一个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传递给构造函数来解决它。
答案 0 :(得分:5)
简化数据上下文(通过T.GetDataContext()创建)仅公开接受EndpointAddress的无参数构造函数和构造函数。如果你想手动设置绑定 - 你可以直接实例化客户端类(它应该位于ServiceTypes中),即:
type WSDL = Microsoft.FSharp.Data.TypeProviders.WsdlService< @"http://www.webservicex.net/RealTimeMarketData.asmx?WSDL">
let client = new WSDL.ServiceTypes.RealTimeMarketDataSoapClient(...)