Ping WCF 服务 [英] Pinging WCF Services

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

问题描述

检查 WCF 服务是否可用的最有效方法是什么.(Pinging) 假设与绑定配置无关.

What is the most efficient way to check if WCF Service is available. (Pinging) It suppose to be binding configuration independent.

我不想用 IsAlive() 方法修改服务合同.理想情况下,我希望 WCF 框架支持它.否则,我们的解决方案是通过添加ServiceAdministration"服务来完成的,该服务与上述服务托管在同一进程中.ServiceAdministration 有对 ServiceHost 的引用,它可以检查其状态.

I prefer not to modify the Service Contracts with IsAlive() method. Ideally, I would expect that the WCF framework supports it. Otherwise, our solution is done by adding "ServiceAdministration" service, which is hosted in the same process as the above service. ServiceAdministration has a reference to the ServiceHost and it can check its State.

推荐答案

我做的两件事是 telnet 检查以确保 WCF 进程打开了套接字.

The two things I do are a telnet check to make sure the WCF process has the socket open.

telnet host 8080

我做的第二件事总是在我的 WCF 合约中添加一个 IsAlive 方法,以便有一个简单的方法可以调用来检查服务主机是否正常运行.

The second thing I do is always add an IsAlive method to my WCF contract so that there is a simple method to call to check that the service host is operating correctly.

public bool IsAlive() {
    return true;
}

这篇关于Ping WCF 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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