C # test whether Web service is available

Source: Internet
Author: User

Turn: http://www.cnblogs.com/xienb/p/3443282.html

WinForm clients often need to call WebService or WCF for data interaction, but the remote service may not exist or the server is unavailable, and the client can only be unavailable by timing out or capturing the exception-aware service. There is actually a COM excuse for using fast detection to detect the state of the service that will be invoked. Reference COM component: Microsoft xml,v3.0, the code is as follows:

  

            String url ="Http://127.0.0.1/MySrv/MsgService.svc"; XMLHTTP http =NewXMLHTTP ();Try{Http.open ("GET", URL,FalseNullNull); Http.send (URL);int status = Http.status; if (Status = = 200 " success  ");} else {Console.WriteLine (  " not available Status:" +status. ToString ()); }} catch {Console.WriteLine (  " not available " ); } 

C # test whether Web service is available (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.