How to consume a third Party Web service (C#)

Introduction

This article will talk about consuming third party web service in your web application. In this we will go by step by step approach.
We have also attached the source for the same.

About Third Party Web Service

In this Demo we have using A Third Party web service for getting Currency conversion rate from one currency to another currency

Web Service URL: http://www.webservicex.com/CurrencyConvertor.asmx?wsdl
Input: Two Currencies
Output: Exchange Rate

Sample Application

Out put of the application will be as shown in the picture below. It just calculates the exchange rate of currancy1 and currency2 and show in 4th column.





Step to consume

1) Create ASP.Net Project
2) Goes to explorer solution and Right Click on the root site and later click in add Web reference. See below image



3) Then a window will open as show in below image.




4) On URL textbox, Type http://www.webservicex.com/CurrencyConvertor.asmx?wsdl. This our Web Service URL

5) Change the Web Reference name “Rate_WS". “Rate_WS" will be the namespace for accessing our CurrencyConvertor

6) Click in the add web reference button

Now our application is ready for accessing the CurrencyConvertor webservice.



protected void Page_Load(object sender, EventArgs e)
{
Rate_WS.CurrencyConvertor ExRate = new Rate_WS.CurrencyConvertor();

lblEuroUsd.Text = ExRate.ConversionRate(Rate_WS.Currency.EUR, Rate_WS.Currency.USD).ToString() ;

lblINRUSD.Text = ExRate.ConversionRate(Rate_WS.Currency.INR, Rate_WS.Currency.USD).ToString();

lblInrEuro.Text = ExRate.ConversionRate(Rate_WS.Currency.INR, Rate_WS.Currency.EUR).ToString();

}


Attachments

  • OutPut (30413-14936-output.bmp)
  • WebRef (30413-14939-WebReferance.bmp)
  • AddWebReferance (30413-14104-image.bmp)
  • ServiceCusumer (30413-14941-ServiceCusumer.zip)
  • Comments

    Author: vicky24 Jan 2010 Member Level: Bronze   Points : 1

    How to use webservice like Gtalk,way2sms.com for Web based Desktop application.
    Pls i require the steps and code.
    reply soon

    Guest Author: VinaySanthosh09 Nov 2012

    Excellent Example i got it can u suggest me a webservice how to send Sms to mobiles and how to send email



  • 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: