如何检查是否一个WCF服务是运营? [英] How to check if a WCF service is operational?

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

问题描述

是否有一个快速和可靠的方法来检查,如果一个WCF服务,并接受请求,建于法也许一些最佳做法?显然,从code。

Is there a quick and reliable way to check if a WCF service is available and accepting requests, perhaps some best practice built in method? Obviously from code.

感谢

推荐答案

由于鲁本斯已经提到的,你可以创建你的服务一个虚拟的平的方法来检查。此工程确定,可能是够你 - :当然,这样的平方法只能保证你的服务是访问和响应

As Rubens already mentioned, you could create a dummy "ping" method on your service to check. This works OK and might be enough for you - BUT: such a ping method of course can only guarantee that your service is reachable and responsive.

在很多情况下,你的服务方法将反过来依赖于其它资源 - 例如你需要从数据库中读取数据,解析XML文件,调出又一服务等,因此,即使的的服务,并响应你的Ping方法根本不保证另一请你的服务一定会成功。

In many cases, your service method will in turn depend on other resources - e.g. you need to read data from a database, parse an XML file, call out to yet another service etc. So even if your service is available and responsive on your Ping method doesn't at all guarantee that another call on your service will succeed.

有一个简单的方法,平安您的服务通常不能检查所有相关系统/资源的可用性。那么到底,这真的是你的只是故事的一半(或更少)可以的检查 - !只是要注意的是

A simple Ping method on your service typically cannot check the availability of all those dependant systems / resources. So in the end, it's really only half (or less) of the story you can check - just be aware of that!

为了使长话短说:你不能真正检查服务是可用,启动和运行 - 你基本上只需要当你需要它来调用它,并ppared处理不好的事情$ P $,像超时,网络链路断等良好的防御性编程实践应用更是如此,在连接性,服务导向的世界!

To make a long story short: you can't really check for a service being available and up and running - you basically just need to call it when you need it, and be prepared to handle bad things, like timeouts, network link broken etc. Good defensive programming practices apply even more so in the connected, service-oriented world!

这篇关于如何检查是否一个WCF服务是运营?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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