Search code examples
silverlightsdktimeoutxamarin.iosslsvcutil

Silverlight WCF "slsvcutil.exe" - How to set timeout


We use the Silverlight SDK to generate our WCF proxies (slsvcutil.exe)

How do we set the connection/response timeout with the resulting class to a different level?

Note: We're using MonoTouch.NET on an iPhone so there is no app.config. All settings must be done in code.


Solution

  • Do you create your own binding and endpoint address then intstaniate the client using those? A simple example (Which includes a timeout option):

    BasicHttpBinding binding = new BasicHttpBinding();
    binding.OpenTimeout = new TimeSpan(0, 0, 10);
    binding.CloseTimeout = new TimeSpan(0, 0, 10);
    binding.SendTimeout = new TimeSpan(0, 0, 30);
    // more attributes for the binding
    
    EndpointAddress endpointAddress = new EndpointAddress("https://mywcfserver.com/WCFService.svc");
    ClientProxy client = new ClientProxy(binding, endpointAddress);
    

    just to note, the bindings you define in the code, should be the same as the binding definited the web service's app.config.