There is a live .NET Web Service which offers all the curreny conversion eg. USD to INR etc.

This WS is available via live URL http://www.webservicex.net/CurrencyConvertor.asmx

This WS has a class CurrecnyConvertor which exposes one Function named ConversionRate and an enum named Currency which exposed the list of all the currencies like USD, INR, AED etc.

As you know Currency conversion will depend on two parameters ConvertFrom and ConvertTo and so the same is expected to be passsed while invoking ConversionRate function.

Here is a detailed list of steps:

1- Add a Web Reference to http://www.webservicex.net/CurrencyConvertor.asmx
2- Rename the Reference name to something more friendly like CurrencyConversionWS
3- In your project create an instance of the added Web service reference
4- On the created object invoke the ConversionRate function.
5- As mentioned above there is an enum which lists all the currencies and so access it directly from the object created.
6- Save the result into a double variable and multiply with your passed amount.
7- Multiply the amount you want to convert to the received conversion rate.

Here is the code you will require to have it all working:

CurrencyConversionWS.
CurrencyConvertor
objWS = new CurrencyConversionWS.CurrencyConvertor();

double usdToinr = objWS.ConversionRate(CurrencyConversionWS.Currency.USD, CurrencyConversionWS.Currency.INR);

double totalAmount = usdToinr * Double.Parse(textBox1.Text);

MessageBox.Show(totalAmount.ToString(),“Total Indian Rupees”);

This is how it will look like:

What are the contents of Service1.asmx

September 7th, 2010 | Posted by Vidya Vrat in ASP .NET - (0 Comments)

In any version of Visual Studio, when you create a WebService, it comes with a default Service1.asmx file. When you double-click on this file it opens Service1.asmx.cs file for you, why? and what is the content in this file then? and how do you view it?

In order to view what is inside Service1.asmx, select the file in Solution-Explorer, right-click, and choose “Open With…”

From the shown dialog, select the option “Source Code(Text) Editor, click OK, you will see content like this:

These are the instructions Service1.asmx have and so it opens the Service1.asmx.cs, whenever you double-click on Service1.asmx, as its .cs file is the CodeBehind.

If you are looking for Web Service project template in Visual Studio 2010 under .NET Framework 4.0 as shown in the image below, you will not find it.

In order to create a WebService using Visual Studio 2010 you need to switch back to .NET Framework 3.5, as shown in the image below, and you will be able to crate a WebServeice project.