Open sidebar
public HttpResponseMessage Get(String xmlBilgi) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "text/xml"); if (xmlBilgi.Equals("fiyat", StringComparison.OrdinalIgnoreCase)) { client.BaseAddress = new Uri("http://www.despecpazar.com/xml/xml_request1.asp?op=f&apr=BayiKodu"); } else if (xmlBilgi.Equals("katalog", StringComparison.OrdinalIgnoreCase)) { client.BaseAddress = new Uri("http://www.despecpazar.com/xml/xml_request1.asp?op=k&apr=BayiKodu"); } else if (xmlBilgi.Equals("stok", StringComparison.OrdinalIgnoreCase)) { client.BaseAddress = new Uri("http://www.despecpazar.com/xml/xml_request1.asp?op=s&apr=BayiKodu"); } HttpResponseMessage response = client.GetAsync("").Result; response.Content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("text/xml"); if (response.IsSuccessStatusCode) { string responseAsString = response.Content.ReadAsStringAsync().Result.Trim(); XDocument xd = XDocument.Parse(responseAsString); String path = HttpContext.Current.Server.MapPath("~/xmller"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string imgPath = ""; if (xmlBilgi.Equals("fiyat", StringComparison.OrdinalIgnoreCase)) { imgPath = Path.Combine(path, "despecFiyat.xml"); } else if (xmlBilgi.Equals("katalog", StringComparison.OrdinalIgnoreCase)) { imgPath = Path.Combine(path, "despecKatalog.xml"); } else if (xmlBilgi.Equals("stok", StringComparison.OrdinalIgnoreCase)) { imgPath = Path.Combine(path, "despecStok.xml"); } if(imgPath.Length >= 1) { xd.Save(imgPath); } return Request.CreateResponse(HttpStatusCode.OK, responseAsString); } else { return Request.CreateResponse(HttpStatusCode.BadRequest, "Bir şey oldu: " + response); } }
Close sidebar
Back
Please note that all pasted data is publicly available.
Twitter
GitHub
Use setting
Back
Please note that all pasted data is publicly available.
Twitter
GitHub
Use setting