c# - SoapHttpClientProtocol/HttpWebClientProtocol 连接状态

标签 c# .net web-services http soap

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

相关文章:

c# - 如何在应用程序窗口 wpf 中保留弹出窗口

c# - 如何通过 SignalR 将遥测数据推送到客户端?

.net - 查询基本类型文档

java - Apache CXF codegen 插件抛出空指针

java - 从 web 服务返回大块二进制数据的最佳方法是什么?

c# - 是什么导致错误 "The "ResolveManifestFiles”任务意外失败。路径中有非法字符

c# - 具有代码生成功能的分层状态图设计器

c# - 使用 itextSharp 从 pdf 中提取文本会更改数字

c# - 使用 FolderBrowserDialog 限制对某些文件夹的访问

c# - 停止向外部发布到 Asp.Net WebForm 页面的能力