码迷,mamicode.com
首页 > Web开发 > 详细

WebService调用方法

时间:2016-07-08 18:06:08      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

private static string HttpClientRequest(string uri, List<KeyValuePair<string, string>> paramList)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.MaxResponseContentBufferSize = 256000;
            httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36");
            HttpResponseMessage response = httpClient.PostAsync(new Uri(uri), new FormUrlEncodedContent(paramList)).Result;
            string result = response.Content.ReadAsStringAsync().Result;
            //用完要记得释放
            httpClient.Dispose();
            return result;
        }

 

WebService调用方法

标签:

原文地址:http://www.cnblogs.com/huweizhong/p/5654143.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!