Web Service

Web Service is an application designed to interact directly with other applications over the internet. Web Services are means for interacting with objects over the Internet. Web service consumers are able to invoke method calls on remote objects by using SOAP and HTTP over the Web. Web Service is language independent and Web Services communicate by using standard web protocols and data formats, such as HTTP,XML,SOAP.
– Web service is the way to publish application’s function on web that can be accessible to the rest of the world.
– Web services are the components that can be used by other applications.
– ASP.NET offers easy way to develop web services, just precede the functions with a special WebMethod () attribute in order them to work as Web Service.
– Web services are built on XML standard and use SOAP protocol that allows them to communicate across different platforms and programming languages.
– Web services easily manage to work across corporate firewalls as they use HTTP protocol which is firewall friendly.
– Web services platform elements are
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)
– The web services are built on internet standards that are not platform or language specific.
– The .Net framework provides in-built classes to build and consume web services.
– The components offered by web services are reusable.
– The examples of web service components can be shipment tracking, translation utility, weather forecasting, sports scores etc.


1)Open Visual Studio and click on File->New->Project
2)In the “New Project” dialog box click on “Asp.Net Empty web application”.
3)Right click on the project name and add new form and rename it as “Default”
4)Right on the project name add new Webservices names “WebServices1”.
5)Add below code in Webservices.cs page.

public string DemoServices()
return "This is an sample example for web services";

6)Add a label control in Default.aspx page and call the web services on the page load event of Default page as shown below.

protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
WebService1 services = new WebService1();
lbl_Display.Text = services.DemoServices();

7)Run the web services page.

Web service 1

8)Click on “DemoServices” link and click “Invoke” button to display the output string “This is an example for Web services”.

Web service 2

9)Use a label control to display the results of methods used in the Web services. Run the “Default” page to view the final output.

Web service 3

Demo Code

Download Demo

Advantages of Web Service

– Web Services are supported on a wide range of platforms.

– Web services may extend its interface and add new methods without affecting the clients as long as they still provide the old methods and parameters.

– A client makes a request to a web service, the web service returns the result, and the connection is closed. There is no permanent connection. This makes it easy to scale up and support many clients at a time.

– Firewalls can pose a challenge for distributed object technologies. The only thing that almost always gets through firewalls is HTTP traffic on ports 80 and 443. Because web services use HTTP, they can pass through firewalls without explicit configuration.