WSDL和BasicHttpBinding的F#类型提供程序

Igo*_*man 4 f# wsdl web-services type-providers

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

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

当我在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>
Run Code Online (Sandbox Code Playgroud)

这无济于事,我仍然遇到一个异常,即maxReceivedMessageSize只有64k,我应该对其进行更改。我在C#中遇到了同样的问题,app.config设置似乎被忽略了,所以我通过将带有这些设置的BasicHttpBinding传递给构造函数来解决了这个问题。

des*_*sco 6

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

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

  • 对于任何好奇的人,此解决方案中的“ ...”都类似于:`new BasicHttpBinding(MaxReceivedMessageSize = 200000L),new EndpointAddress(address)` (7认同)