Click here to Skip to main content
11,433,997 members (61,082 online)
Click here to Skip to main content

Currency Conversion Using Web Services

, 9 Nov 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
This article teaches how to use a currency converter Web Service from www.xmethods.net in order to get exchange rates between currencies.

Introduction

I was navigating the web looking for a currency converter and, finally, I found an article by Phil Williams that explains currency conversion using Web Services. So I based this ASP.NET example on that article, and I have tries to make a little bit easier implementation using the ASP.NET environment. You will find the original article here: "Currency Conversion Using Web Services" by Phil Williams. Now, let's focus on the program. This article shows how to implement the currency converter Web Service from http://www.xmethods.net/ in order to get the exchange rates between currencies; the countries list is available in the xmethods website.

Step 1

Start a new ASP.NET project. In the web form, you must create three labels, named Trm (it will show US dollars in Colombian Pesos), Euro (same case but with Euro), Euro_Us (Euro in dollars).

Step 2

The second step is to add the Web Service reference to the third party Web Service, but how?? Go to the Solution Explorer, right click on the root, and click on Add Web Reference.

Sample screenshot

Sorry about the Spanish language in the screenshot, that's my mother language. In this page, you must specify the Web Service URL and click on Go. The URL is http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl. Now you will see all the methods available for the Web Service; this one just has one: the GetRate() Web Method.

  • Change the Web Reference name to any string; in this case, it will be Rate_WS.
  • Click on the Add Web Reference button.

Sample screenshot

Add Web Reference Wizard

Now you will be able to invoke the GetRate() method from your program.

Step 3

In the page_load event, add these 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 country names to what you want; the list of countries supported is available at http://www.xmethods.net/. This is an easy implementation for a basic Web Service. Feel 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)

Share

About the Author

Britney S. Morales
Web Developer
Colombia Colombia
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.


Comments and Discussions

 
Generalservice unavailable Pin
WilliamAPP16-Jul-09 7:05
memberWilliamAPP16-Jul-09 7:05 
Questionis this service currently unavailable? Pin
Samir NIGAM25-Jun-09 1:11
mvpSamir NIGAM25-Jun-09 1:11 
GeneralHola justo lo que necesitaba Pin
Member 335868713-Jun-09 6:40
memberMember 335868713-Jun-09 6:40 
Questioncan I ? Pin
Muneer Safi3-Jun-09 21:31
memberMuneer Safi3-Jun-09 21:31 
GeneralCómo es que... Pin
Rugal13-Apr-09 21:25
memberRugal13-Apr-09 21:25 
GeneralRevision currency convertion Pin
Member 458891819-Mar-09 5:06
memberMember 458891819-Mar-09 5:06 
GeneralRe: Revision currency convertion Pin
Britney S. Morales19-Mar-09 11:45
memberBritney S. Morales19-Mar-09 11:45 
GeneralRe: Revision currency convertion Pin
Member 458891820-Mar-09 8:14
memberMember 458891820-Mar-09 8:14 
GeneralRe: Revision currency convertion Pin
WilliamAPP18-May-09 12:15
memberWilliamAPP18-May-09 12:15 
GeneralAsking UID , Pwd and domain Pin
Member 20715714-Mar-09 0:08
memberMember 20715714-Mar-09 0:08 
QuestionCurrency webservice url not working Pin
Member 425508824-Dec-08 21:55
memberMember 425508824-Dec-08 21:55 
GeneralNO hay problema Pin
vladi100020-Nov-08 10:17
membervladi100020-Nov-08 10:17 
GeneralOther URL [modified] Pin
Zwerver14-Sep-08 23:44
memberZwerver14-Sep-08 23:44 
GeneralWeb Service given by u is not working Pin
vasavi.polisetty13-Jul-08 23:40
membervasavi.polisetty13-Jul-08 23:40 
GeneralRe: Web Service given by u is not working Pin
juand1620-Aug-08 12:13
memberjuand1620-Aug-08 12:13 
Hi,

You can use this webservice:

www.webservicex.net/CurrencyConvertor.asmx[^]

Best Regards,


Juan Daniel
GeneralWeb Service not connecting.. Pin
sircutbreaker.com27-Nov-07 8:40
membersircutbreaker.com27-Nov-07 8:40 
Generalproblem with the service link Pin
sandeepram15-Nov-07 3:10
membersandeepram15-Nov-07 3:10 
GeneralGorgeous Pin
Avi duke17-Jul-07 3:54
memberAvi duke17-Jul-07 3:54 
GeneralRe: Gorgeous Pin
Britney S. Morales28-Sep-07 5:43
memberBritney S. Morales28-Sep-07 5:43 
GeneralProblem while implementing same webservice for windows based Device apllication Pin
shakthi_nandivada26-Jun-07 15:46
membershakthi_nandivada26-Jun-07 15:46 
GeneralRe: Problem while implementing same webservice for windows based Device apllication Pin
Britney S. Morales27-Jun-07 11:57
memberBritney S. Morales27-Jun-07 11:57 
GeneralRe: Problem while implementing same webservice for windows based Device apllication Pin
shakthi_nandivada27-Jun-07 17:32
membershakthi_nandivada27-Jun-07 17:32 
Generalnice example Pin
marwamay10-Jun-07 0:21
membermarwamay10-Jun-07 0:21 
GeneralRe: nice example Pin
Britney S. Morales12-Jun-07 10:38
memberBritney S. Morales12-Jun-07 10:38 
GeneralGeca Pin
Geca25-May-07 3:47
memberGeca25-May-07 3:47 
GeneralRe: Geca Pin
Britney S. Morales12-Jun-07 10:37
memberBritney S. Morales12-Jun-07 10:37 
GeneralClean and simple Pin
Member #328882829-Jan-07 22:28
memberMember #328882829-Jan-07 22:28 
Generalhello Pin
chernobyl24-Jan-07 17:33
memberchernobyl24-Jan-07 17:33 
GeneralRe: hello Pin
Britney S. Morales25-Jan-07 2:11
memberBritney S. Morales25-Jan-07 2:11 
GeneralNice example on web service Pin
Sheel Gohe9-Jan-07 6:37
memberSheel Gohe9-Jan-07 6:37 
GeneralRe: Nice example on web service Pin
Britney S. Morales9-Jan-07 11:29
memberBritney S. Morales9-Jan-07 11:29 
GeneralCode not working Pin
LeonXWizard1-Dec-06 5:35
memberLeonXWizard1-Dec-06 5:35 
GeneralRe: Code not working Pin
Britney S. Morales1-Dec-06 6:40
memberBritney S. Morales1-Dec-06 6:40 
GeneralI prefer to use this Web Service Pin
Andri Yadi26-Nov-06 22:14
memberAndri Yadi26-Nov-06 22:14 
GeneralRe: I prefer to use this Web Service Pin
Munni1128-Sep-07 6:05
memberMunni1128-Sep-07 6:05 
GeneralCode? what Code? I am just here to look at her picture. Pin
rishen sukai23-Nov-06 20:54
memberrishen sukai23-Nov-06 20:54 
JokeI'm still looking at your picture Pin
kevferron10-Nov-06 13:27
memberkevferron10-Nov-06 13:27 
GeneralThanks ;) Pin
Polymorpher27-Sep-06 9:20
memberPolymorpher27-Sep-06 9:20 
GeneralRe: Thanks ;) Pin
leppie10-Nov-06 0:09
memberleppie10-Nov-06 0:09 
GeneralRe: Thanks ;) Pin
Polymorpher10-Nov-06 14:54
memberPolymorpher10-Nov-06 14:54 
GeneralCode not working properly at my end Pin
Ecologic6-Sep-06 22:11
memberEcologic6-Sep-06 22:11 
GeneralRe: Code not working properly at my end [modified] Pin
britneyssssers7-Sep-06 3:40
memberbritneyssssers7-Sep-06 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150428.2 | Last Updated 9 Nov 2006
Article Copyright 2006 by Britney S. Morales
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid