首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SoapHttpClientProtocol/HttpWebClientProtocol连接状态

SoapHttpClientProtocol/HttpWebClientProtocol连接状态
EN

Stack Overflow用户
提问于 2010-10-22 22:19:21
回答 2查看 1.4K关注 0票数 3

我有一个基于SoapHttpClientProtocol的WebService参考(.NET CF 3.5)。我的问题是-除了调用web方法之外,有没有一种方法可以确定是否建立了到WebService的连接?我是否可以随时检查底层连接是否已建立并获取其状态?

问候

EN

回答 2

Stack Overflow用户

发布于 2011-05-14 04:33:39

您可以在客户端上检查通信状态。

代码语言:javascript
复制
using (XServiceSoapClient client = new XServiceSoapClient())
{
   client.State;
}

public enum CommunicationState
{
    // Summary:
    //     Indicates that the communication object has been instantiated and is configurable,
    //     but not yet open or ready for use.
    Created = 0,
    //
    // Summary:
    //     Indicates that the communication object is being transitioned from the System.ServiceModel.CommunicationState.Created
    //     state to the System.ServiceModel.CommunicationState.Opened state.
    Opening = 1,
    //
    // Summary:
    //     Indicates that the communication object is now open and ready to be used.
    Opened = 2,
    //
    // Summary:
    //     Indicates that the communication object is transitioning to the System.ServiceModel.CommunicationState.Closed
    //     state.
    Closing = 3,
    //
    // Summary:
    //     Indicates that the communication object has been closed and is no longer
    //     usable.
    Closed = 4,
    //
    // Summary:
    //     Indicates that the communication object has encountered an error or fault
    //     from which it cannot recover and from which it is no longer usable.
    Faulted = 5,
}
票数 1
EN

Stack Overflow用户

发布于 2011-05-14 23:54:00

我非常确定,除非在接口上调用方法,否则不会建立任何连接。特别是因为通信是基于HTTP的。

在我正在做的一个项目中,我实际上在服务器上创建了一个客户端可以调用的NOP方法。我使用它来确定提供的连接信息和登录凭据是否有效(通过使用try-catch块)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3997711

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档