How to get current currency exchange rate value using web services?


In this article I have explained about how to get exchange rate values between two currency i.e. Receiver currency and purchaser currency. I used www.webservicex.net web service for get current exchange rate amount. Using this application concept you get any currency rate in the world.

Description:
Currency rate is differing day by day, for this reason we can check currency rate amount using some other web service provider. If you like this application then use side bar of your website with title "Get Currency Rate" user use this application and get exchange rate with use of your website.

How to get exact currency rate?
We can get exact currency rate only by using web services.


protected void Button1_Click(object sender, EventArgs e)
{
try
{
string xmlResult = null;
string url;
url = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" + TextBox1.Text + "&ToCurrency=" + TextBox2.Text + "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader resStream = new StreamReader(response.GetResponseStream());
XmlDocument doc = new XmlDocument();
xmlResult = resStream.ReadToEnd();
doc.LoadXml(xmlResult);
Label1.Text = "Current Exchange Rate for " + TextBox1.Text.ToUpper() + " ---> " + TextBox2.Text.ToUpper() + " value " + doc.GetElementsByTagName("double").Item(0).InnerText;
}
catch(Exception ex)
{
Label1.Text="Not a valid Currency or Try again later";
}
}

Source Code Detail:
Here with I have attached entire source code for Exchange Rate Application including client side and server side code. Download it and try to get Exchange Rate and also if you like then add this application in your site.
Front End : ASP.NET
Code Behind : C#

Conclusion:
I hope this Article is help to you get currency exchange rate.


Attachments

  • ExchangeRate_using_Webservice (42821-15954-ExchangeRate.rar)
  • Comments

    No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: