HttpRequestMessage http_req_msg = new HttpRequestMessage();
http_req_msg.Method = HttpMethod.Get;
http_req_msg.Headers.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
http_req_msg.RequestUri = new Uri("http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl");                       

HttpClient httpclient;            
HttpClientHandler httphandler;            

httphandler = new HttpClientHandler();
httphandler.AllowAutoRedirect = false;
httphandler.UseCookies = false;

httpclient = new HttpClient(httphandler);
var task = httpclient.SendAsync(http_req_msg);
task.Result.EnsureSuccessStatusCode();

HttpResponseMessage response = task.Result;

var result = response.Content.ReadAsStringAsync();
string responseBodyAsText = result.Result;
responseBodyAsText = responseBodyAsText.Replace("<br>", Environment.NewLine); // Insert new lines

MessageBox.Show(responseBodyAsText);

 

 posted on 2014-07-09 19:12  生活奋斗  阅读(300)  评论(0编辑  收藏  举报