Hello,
To create the Web service
1. In Solution Explorer, right-click the Web site name (http://localhost/TemperatureWebService), and then click Add New Item.
2. Under Visual Studio installed templates, click Web Service, and then in the Name box, type Convert.
3. Make sure that the Place code in separate file check box is selected, and then click Add.
1. Add the following code inside the class, after the HelloWorld method:
[System.Web.Services.WebMethod()]
public double FahrenheitToCelsius(double Fahrenheit)
{
return ((Fahrenheit - 32) * 5) / 9;
}
[System.Web.Services.WebMethod()]
public double CelsiusToFahrenheit(double Celsius)
{
return ((Celsius * 9) / 5) + 32;
}
2. After you have entered the functions, save the file.
To test the Web service:
1. In Solution Explorer, click Convert.asmx, and then press CTRL+F5.
The Web service is invoked and a page appears in the browser that shows the methods that are exposed by the Web service.
2. Click CelsiusToFahrenheit, which invokes that method.
A page appears that prompts you for parameter values for the CelsiusToFahrenheit method.
3. In the Celsius box, type 100, and then click Invoke.
A new window appears that displays the XML that the Web service returns when the CelsiusToFahrenheit method is invoked. The value 212 appears in the XML.
4. Close the browser that contains the method results.
5. In the original browser, click Back to return to the list of methods.
6. Click FahrenheitToCelsius and test to make sure that the method is returning the results that you expect.
If you type 212, the FahrenheitToCelsius method will return 100.
7. Close the browser.
You have finished creating the Web service; the next step is to use it.
For more reference follow the below link:
https://msdn.microsoft.com/en-us/library/8wbhsy70(v=vs.80).aspx
http://www.codemag.com/Article/0701041
Hope this will help you.
Mark the answer if it helps you.
Regards,
Nirav Lalan
DNS Gold Member
"If you can dream it, you can do it."