|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionI 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. FirstStart 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
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.
|
||||||||||||||||||||||