检测 wcf 服务是否被激活 [英] Detect if wcf service is activated

查看:35
本文介绍了检测 wcf 服务是否被激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 WP8 应用程序.我注意到如果服务器正常工作,一切正常,但如果服务器关闭,我会得到一个例外.

I'm making a WP8 application. I noticed that if the server is working everything works good, but if the server is down I get an exception.

在使用他的方法之前wcf服务是否激活,如何在代码中检查?

How can I check in the code if the wcf service is activated before using his methods?

推荐答案

在您的 Web 服务中实现一个 no-op 方法并以低超时时间调用它.如果有效,则服务已启动.如果呼叫因任何原因失败,则服务将关闭.

Implement a no-op method in your web-service and call it with a low timeout. If it works, the service is up. If the call fails for whatever reason, the service is down.

实际上,为什么服务器会经常宕机?也许更容易确保它始终可用.

Actually, why is the server even down regularly? Maybe it is easier to ensure that it is available at all times.

这篇关于检测 wcf 服务是否被激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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