C# SoapHttpClientProtocol/HttpWebClient协议连接状态

C# SoapHttpClientProtocol/HttpWebClient协议连接状态,c#,.net,web-services,http,soap,C#,.net,Web Services,Http,Soap,我有一个基于SoapHttpClientProtocol的Web服务参考(.NET CF 3.5)。我的问题是-除了调用web方法之外,是否有其他方法可以确定是否建立了到WebService的连接?我可以随时检查基础连接是否已建立并获取其状态吗 关于您可以检查客户端上的通信状态 using (XServiceSoapClient client = new XServiceSoapClient()) { client.State; } public enum CommunicationSt

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


关于

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

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,
}

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


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

您需要通过代码来确定吗?