/// <summary> /// 请求url /// </summary> /// <param name="client"></param> /// <param name="url"></param> /// <param name="httpMethod"></param> /// <returns></returns> private static string DoRequest(IDiscoveryClient client, string url, HttpMethod httpMethod) { string result = ""; try { Uri uri = client.LookupService(new Uri(url)); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = httpMethod.Method; try { using (Stream stream = ((HttpWebResponse)request.GetResponse()).GetResponseStream()) { result = new StreamReader(stream, Encoding.UTF8).ReadToEnd(); } } catch (WebException exception1) { using (Stream stream2 = ((HttpWebResponse)exception1.Response).GetResponseStream()) { result = new StreamReader(stream2).ReadToEnd(); } } } catch (Exception exception) { result = exception.Message; } return(result); }