Thursday, January 10, 2008

How we use Web Services in our Web page?

free web services available :http://www.webservicex.net/WS/WSDetails.aspx?WSID=10&CATID=2

(This service is used for currency convertor this is free service tht is available on net )

Now go to ur website where u want to use this service and

From the website menu- Add the web References and paste this url in url column n then click on GO.It will tak few sec to connect and onces it connected to ur web service, Web reference name option actvate, give any proxy name there like aa,bb etc which u like. Click on Add reference n this window automatically closed n connection established.

With the help of Proxy name i.e aa we can access all the properties of this webservice in our website.

Now for the consumption of this webservice make a one object of this webservice :

public partial class _Default : System.Web.UI.Page
{
aa.CurrencyConvertor obj = new aa.CurrencyConvertor();

after u create object

go to ur .aspx page n put some textbox,button etc according to ur reqirement n then link tht button to ur webservice object

for example

we place 1 textbox where we want to show the currencyconverter result
and 1 button

On the click of this button result appeared in textbox

protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = obj.ConversionRate(aa.Currency.ZMK, aa.Currency.ZWD).ToString();

}


here ZMK,ZWD are the country code

No comments: