![]() |
Web Development »
ASP.NET »
General
Beginner
License: The Code Project Open License (CPOL)
Currency Conversion using Web ServicesBy Britney S. MoralesThis article is to teach how to implement the currency converter Web Service from www.xmethods.net in order to get the exchange rates between countries' money |
C# 1.0, C# 2.0.NET 1.1, .NET 2.0, WinXP, ASP.NET, WebForms, VS.NET2003, VS2005, Dev
|
||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
I was navigating the web looking for a currency converter between the different countries money, finally, I found an article from Phil Williams who explain a Currency Conversion using web Services, so I based this ASP.NET example in that article and I try to make a little bit easy the implementation using the ASP.NET environment. You will find the original article in google using the sentence, "Currency Conversion using Web Services by Phil Williams." Already the presentation, now lets focus in the program. This article is to teach how to implement the currency converter Web Service from the http://www.xmethods.net/ in order to get the exchange rates between countries money, the countries list is in the xmethods website.
Start a new asp.net project. In the web form you must to create three labels, their name are Trm (it will show the US dollars at Colombians Pesos), Euro(Same Case but with Euro), Euro_Us(Euro in dollar).
The second step is to add the web service reference to third part Web Service, How?? Goes to explorer solution, do right click over the root site, later click in add Web reference.
Check the image 1
Sorry about the Spanish language, that's my mother language. In this page you must to write the web Service url address, and click in go. The URL is http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl. Now you will see all the implements methods for this Web Service, this WS just have one, GetRate() Web Method.
Add web reference wizard
Now it's already the Web Service reference to third party program, you are able to invoice the GetRate() method from your program.
Third
At the page_load event add the next lines.
protected void Page_Load(object sender, EventArgs e)
{
try{
Rate_WS.CurrencyExchangeService to_currency = new Rate_WS.CurrencyExchangeService();
float euro_us = to_currency.getRate("euro", "
float us_pesos = to_currency.getRate("
float euro_pesos = to_currency.getRate("euro", "colombia");
Trm.Text = us_pesos.ToString();
Euro.Text = euro_pesos.ToString();
Euro_Us.Text = euro_us.ToString();
}
catch(Exception){}
}
Change the countries names for any you want, the list of countries support is in http://www.xmethods.net/. This is an easy implementation for a basic web service, fell free to make any changes.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 9 Nov 2006 Editor: |
Copyright 2006 by Britney S. Morales Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |