Click here to Skip to main content
6,634,665 members and growing! (15,805 online)
Email Password   helpLost your password?
Web Development » ASP.NET » General     Beginner License: The Code Project Open License (CPOL)

Currency Conversion using Web Services

By Britney S. Morales

This 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
Posted:5 Sep 2006
Updated:9 Nov 2006
Views:48,370
Bookmarked:24 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
13 votes for this article.
Popularity: 3.04 Rating: 2.73 out of 5
3 votes, 23.1%
1
3 votes, 23.1%
2

3
2 votes, 15.4%
4
5 votes, 38.5%
5

Introduction

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.

First

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).

Second

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

Sample screenshot

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.

  • Change the Web Reference name to Any String, in this case will be Rate_WS.
  • Click in the add web reference button.
Sample screenshot

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", "united states");

float us_pesos = to_currency.getRate("united states", "colombia");

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Britney S. Morales


Member
Web Developer during 3 years and counting, i worked over my school website by two years, right now im webmaster at World Wowan foundation banking in my home city.

Please forgive my pictures examples, they are at spanish language because its my mother language.


Occupation: Web Developer
Location: Colombia Colombia

Other popular ASP.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 43 (Total in Forum: 43) (Refresh)FirstPrevNext
AnswerAnother solution for this reference Pinmemberjaviernovoa8717:41 23 Sep '09  
Generalservice unavailable PinmemberWilliamAPP7:05 16 Jul '09  
Generalis this service currently unavailable? PinmvpSamir NIGAM1:11 25 Jun '09  
GeneralHola justo lo que necesitaba PinmemberMember 33586876:40 13 Jun '09  
Generalcan I ? PinmemberMuneer Safi21:31 3 Jun '09  
GeneralCómo es que... PinmemberRugal21:25 13 Apr '09  
GeneralRevision currency convertion PinmemberMember 45889185:06 19 Mar '09  
GeneralRe: Revision currency convertion PinmemberBritney S. Morales11:45 19 Mar '09  
GeneralRe: Revision currency convertion PinmemberMember 45889188:14 20 Mar '09  
GeneralRe: Revision currency convertion PinmemberWilliamAPP12:15 18 May '09  
GeneralAsking UID , Pwd and domain PinmemberMember 20715710:08 4 Mar '09  
QuestionCurrency webservice url not working PinmemberMember 425508821:55 24 Dec '08  
GeneralNO hay problema Pinmembervladi100010:17 20 Nov '08  
GeneralOther URL [modified] PinmemberZwerver23:44 14 Sep '08  
GeneralWeb Service given by u is not working Pinmembervasavi.polisetty23:40 13 Jul '08  
GeneralRe: Web Service given by u is not working Pinmemberjuand1612:13 20 Aug '08  
GeneralWeb Service not connecting.. Pinmembersircutbreaker.com8:40 27 Nov '07  
Generalproblem with the service link Pinmembersandeepram3:10 15 Nov '07  
GeneralGorgeous PinmemberAvi duke3:54 17 Jul '07  
GeneralRe: Gorgeous PinmemberBritney S. Morales5:43 28 Sep '07  
GeneralProblem while implementing same webservice for windows based Device apllication Pinmembershakthi_nandivada15:46 26 Jun '07  
GeneralRe: Problem while implementing same webservice for windows based Device apllication PinmemberBritney S. Morales11:57 27 Jun '07  
GeneralRe: Problem while implementing same webservice for windows based Device apllication Pinmembershakthi_nandivada17:32 27 Jun '07  
Generalnice example Pinmembermarwamay0:21 10 Jun '07  
GeneralRe: nice example PinmemberBritney S. Morales10:38 12 Jun '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin 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