简体   繁体   English

确定WCF net.tcp端点地址是否有效

[英]Determining if a WCF net.tcp endpoint address is valid

I am building a tool for validating if all the touchpoints (DB connection strings, mail servers, web services, WCF services, etc.) used by a set of applications are accessible after a disaster recovery migration to an off-site location. 我正在构建一个工具,用于在灾难恢复迁移到异地之后验证一组应用程序使用的所有接触点(数据库连接字符串,邮件服务器,Web服务,WCF服务等)是否可访问。

The tool must check whether a given net.tcp endpoint address is valid and accessible, without generating a client proxy, and without regard to the binding or behavior used by the actual WCF client. 该工具必须检查给定的net.tcp终结点地址是否有效且可访问,而无需生成客户端代理,也不必考虑实际WCF客户端使用的绑定或行为。 The tool does not need to invoke any service method, and will only be run by system administrators using highly privileged domain credentials. 该工具不需要调用任何服务方法,只能由系统管理员使用特权较高的域凭据运行。

It is easy to do this for HTTP-based services: 对于基于HTTP的服务,这样做很容易:

hwrRequest = (HttpWebRequest)WebRequest.Create(i_WebServiceUrl);
hwrRequest.Timeout = i_nTimeoutSeconds * 1000;
hwrResponse = (HttpWebResponse)hwrRequest.GetResponse();
if (hwrResponse.StatusCode == HttpStatusCode.OK)
:
:

Is there an equivalent technique for WCF net.tcp services? WCF net.tcp服务是否有等效的技术?

First of all, why do you expect your WebRequest code to work? 首先,为什么期望您的WebRequest代码能够正常工作? If the service isn't generating metadata, or is otherwise not responding to an HTTP GET verb, then your response will time out. 如果服务没有生成元数据,或者没有响应HTTP GET动词,则您的响应将超时。

I recommend creating an administrative service contract and implementing it in all of your services. 我建议创建一个管理服务合同并在所有服务中实施它。 You may simply want to add a Ping() method to that contract, but you may also decide to add other methods. 您可能只是想向该合同添加Ping()方法,但是您可能还决定添加其他方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM