Connection Status SoapHttpClientProtocol / HttpWebClientProtocol

I have a WebService (.NET CF 3.5) link based on SoapHttpClientProtocol. My question is: is there a way to determine if a connection to a WebService is established other than calling a web method? Is it possible at any time to verify that the basic connection is established and get its status?

Hi

+3
source share
2 answers

You can check the communication status on the client.

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
source

I am sure that the connection is not made if you do not call the method on the interface. Moreover, the connection is based on HTTP.

, , NOP , . , , ( try-catch).

0

Source: https://habr.com/ru/post/1770930/


All Articles