ASP.NET调用WCF服务
代码如下:
/// <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