Creating Web Service using ASP .NET

To know about basics of web service read this article.

1.   Create an ASP .NET web service application using Microsoft Visual Studio.
2. Take a scenario that we have to convert Celsius to Fahrenheit and vice versa.
3.   Below is the code for our scenario:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
    public Service () {

        //Uncomment the following line if using designed components 
    [WebMethod(Description = "Convert Celsius to Fahreinheit")]
    public double ToFahreinheit(double C)
        return C * (9.0/5.0) + 32;        

    [WebMethod(Description = "Convert Fahreinheit to Celsius")]
    public double ToCelsius(double F)
        return (F - 32) * (5.0/9.0);        
4. Build and run the web service, you will see the following output:
5.Now, we will test the web service by giving input values and invoke it.Below are the screen shots which will show the input given and the results:

Hope this article, explains you about creating and running a simple web service using ASP .NET
Here is the link to download the full source code.

To know about consuming a web service using ASP .NET read this article.


Popular posts from this blog

CAML Query tutorial for SharePoint

Cascading dropdown (or) Filtered Values in Lookup Columns in SharePoint

Programmatically get SharePoint Users with Group Name