Monotouch/WCF:为什么不能覆盖 wcf 绑定超时设置 [英] Monotouch/WCF: why cannot override the wcf binding timeout setting

查看:32
本文介绍了Monotouch/WCF:为什么不能覆盖 wcf 绑定超时设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Monotouch/WCF:为什么不能覆盖 wcf 绑定默认超时设置:

Monotouch/WCF: why cannot override the wcf binding default timeout setting:

public class MyServiceClient : ClientBase<IMyContract>,IMyContract
{ ... }

public void test() {
        BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
        basicHttpBinding.Name = "basicHttpBinding";
        basicHttpBinding.MaxBufferSize = int.MaxValue;
        basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;
        basicHttpBinding.ReceiveTimeout = TimeSpan.FromSeconds(10.0);
        basicHttpBinding.SendTimeout = TimeSpan.FromSeconds(10.0);
        basicHttpBinding.CloseTimeout = TimeSpan.FromSeconds(5.0);
        basicHttpBinding.OpenTimeout = TimeSpan.FromSeconds(5.0);

       MyServiceClient client = New MyServiceClient(basicHttpBinding, new EndPointAddress(...));
       client.Test();
     }

//虽然我把 OpenTimeout 设置为 5 秒,但是当我关闭服务器服务(或关闭 iphone 的 wifi & 网络)时,它仍然尝试在后台连接服务,直到默认的 1 分钟超时,真奇怪!为什么?谢谢.

// Althought I set the OpenTimeout to 5 seconds, but when I close the server service(or close the iphone's wifi & network), it still try to connect to the service in the background until the default 1 miniute timeout, it's strange! Why? thanks.

顺便说一句,monotouch/iPhone 中的异常在 1 分钟后抛出,类型是 TimeoutException(message:The operation has timed-out.) 而不是 FaultException 或 CommunicationException).如果上面的代码在windows .net客户端调用,应该抛出CommunicationException.

btw, the exception in monotouch/iPhone throw after 1 minutes,the type is TimeoutException(message:The operation has timed-out.) not the FaultException or CommunicationException). If the above code invoke in windows .net client, it should be throw the CommunicationException.

推荐答案

xamarin 团队回复:serviceClient.innerchannel.operationtimeout = ...谢谢.

xamarin team reply: serviceClient.innerchannel.operationtimeout = ... thanks.

这篇关于Monotouch/WCF:为什么不能覆盖 wcf 绑定超时设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆