public ResponseData Geocode(RequestData requestData) { var resp = new ResponseData(); string url = "https://maps.googleapis.com/maps/api/geocode/xml?address={0}&key={1}"; WebResponse response = null; try { url = string.Format(url, requestData.Address, GoogleGeocodeApiKey); var request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; response = request.GetResponse(); using (var reader = new StreamReader(response.GetResponseStream())) { resp.Data = reader.ReadToEnd(); } } catch (Exception e) { throw e; } finally { if (response != null) { response.Close(); } } return resp; }
public ResponseData Geocode(RequestData requestData) { var resp = new ResponseData(); string url = "http://geocode-maps.yandex.ru/1.x/?geocode={0}&lang=tr-TR"; WebResponse response = null; try { url = string.Format(url, requestData.Address); var request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; response = request.GetResponse(); using (var reader = new StreamReader(response.GetResponseStream())) { resp.Data = reader.ReadToEnd(); } } catch (Exception e) { throw e; } finally { if (response != null) { response.Close(); } } return resp; }