ASP.NET调用WCF服务

时间:2022-07-08 16:49:11

代码如下:

        /// <summary>
        /// 调用HTTP(Get)
        /// </summary>
        /// <param name="url">服务地址</param>
        public static void GetHttp(string url)
        {
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "GET";
            httpWebRequest.Timeout = 20000;
            HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            httpWebResponse.Close();
        }

这里的URL表示一个服务的完整地址,比如:192.168.0.164:8100/sdms/VerifyUser/admin/12345678/hw