private void btnConverter_Click(object sender, RoutedEventArgs e)
{
double CurrencyAmount;
//Check for a numeric value entered into the Amount textbox
try
{
CurrencyAmount = double.Parse(TxtAmount.Text);
}
catch
{
LblResult.Text = "Please enter a Numeric Value!";
return;
}
try
{
string Result = null;
string url;
//Call the web service to get the exchange rate for the two currencies selected by the user
url = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" + cmbDdlFromCurrency.SelectedValue + "&ToCurrency=" + cmbDdlToCurrency.SelectedValue + "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader Stream = new StreamReader(response.GetResponseStream());
XmlDocument doc = new XmlDocument();
Result = Stream.ReadToEnd();
doc.LoadXml(Result);
//Retrieve the conversion rate
string NewConversionRate = doc.GetElementsByTagName("double").Item(0).InnerText;
////Convert the conversion rate string to a double
double ConversionRate = double.Parse(NewConversionRate);
//Calculate the currency exchange
double ConvertedAmount = CurrencyAmount * ConversionRate;
////Display the results on the Default.aspx page
LblResult.Text = Convert.ToString(ConvertedAmount);
//TxtAmount.Text + " " + cmbDdlFromCurrency.SelectedItem + " = " + dblConverted + " " + cmbDdlToCurrency.SelectedItem;
}
catch
{
LblResult.Text = "Oops..Web Service Not available. Try again later";
}
}
i tried to created the currency converter use in webservice but it doesn't work every time i executed the programmer its display Oops error please anyone can tell me what is the error and what i want to do ???? and i created this code for wpf application ..please help to solve this problem :)