gpt4 book ai didi

c# - SoapHttpClientProtocol/HttpWebClientProtocol 连接状态

转载 作者:可可西里 更新时间:2023-11-01 16:22:28 26 4
gpt4 key购买 nike

我有一个基于 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,
}

关于c# - SoapHttpClientProtocol/HttpWebClientProtocol 连接状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3997711/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com