4
votes

When I use a WSDL service in C# I am able to pass two parameters to the constructor; BasicHttpBinding and EndpointAddress

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

When I use the WSDL Type provider in F# I am only allowed to call the constructor without any parameters or with one parameter of type BasicHttpBinding. So how do I set the parameters like MaxReceivedMessageSize or MaxBufferSize?

EDIT:

If I put this to the app.config of the Azure Worker role

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

It does not help, I still get an exception that maxReceivedMessageSize is only 64k and I should change it. I had the same problem in C#, the app.config setting seemed to be ignored so I solved it by passing an BasicHttpBinding with these settings to the constructor.

1
From MSDN: "There are two ways to specify configuration settings for a WSDL connection, by using the app.config file for the project, or by using the static type parameters in the type provider declaration". I guess app.config approach is more flexible since when there will be multiple applications using the same F# library, you may need configuring them individually. Azure doesn't seem to be an obstacle for app.config, too. - bytebuster
@bytebuster I edited my post. The settings from app.config do not seem to be used - Igor Kulman

1 Answers

7
votes

simplified data context (that is created via T.GetDataContext()) exposes only parameterless constructor and constructor that accepts EndpointAddress. If you want to setup bindings manually - you can instantiate client class directly (it should be located inside ServiceTypes) i.e.:

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