Introduction - ASP.NET Web Services

In the previous article I explained about Introduction to .Net Framework, View ASP.Net View Trace Information, Asp.Net - How to Send Email Via Gmail or Gmail SMTP Server, ASP.Net - IIS Search Engine Optimization Toolkit. In this article I will explain Web Services in asp .net .

Web Services Basics
A Web Service is programmable application logic accessible through standard Web protocols such as SOAP. SOAP uses XML for data description and HTTP for transport to encode and transmit application data. Web Service is an application that is designed to interact directly with other applications over the internet. In simple sense, Web Services are means for interacting with objects over the Internet.

Web Services are Language IndependentProtocol IndependentPlatform Independent and It assumes stateless service architecture.

We will discuss more on web service as the article proceeds. Before that let’s understand bit on how web service comes into picture.

A Brief History Of Web Services
As I have mention before that Web Service is nothing but means for interacting with objects over the Internet.
  • Initially Object Oriented Language comes which allow us to interact with two object within same application.
  • Comes to Component Object Model (COM) which allows interacting two objects on the same computer, but in different applications.
  • Comes to Distributed Component Object Model (DCOM) which allows interacting two objects on different computers, but within same local network.
Web Services Protocols
Web Services communicate by using standard web protocols and data formats, such as HTTP, XML and SOAP.

Advantages of Web services
Web Service messages are formatted as XML, a standard way for communication between two incompatible systems, and this message is sent via HTTP, so that they can reach to any machine on the internet without being blocked by firewall.

C# - Web Services Examples
This Web Service will retrieve Customer List Country Wise and return as dataset to client application for display. Follow the below steps:

Step 1: Create a Web Service Application by File -> New -> Web Site -> Web Services



Step 2: Lets create a logic to implement a web service, for example:
    public int Sum(int a, int b)
        return a + b;


NoteAttaching the WebMethod attribute to a Public method indicates that you want the method exposed as part of the XML Web service.

Step 3:
Now build your web service and run it for testing by pression F5 function key from your keyboard.


By pressing "Invoke" button will generate XML File. So you are done creating web service application.


Note: There are few facts about Web Service in .net :-
  • Each Response from web service is a new object, with a new state.
  • Web Service is asynchronous because the request object from the client application and the response object from the web service are unique SOAP envelopes that do not require shared connection.
  • This allows client application and the web service to continue processing while the interaction is on-going.
  • Instead of a user interface, it provides a standard defined interface called a contract.
Please leave your comments, suggestions and queries about this post in the comment sections in order for me to improve my writing skills and to showcase more useful posts. Thanks for reading! :)

Post a Comment

  1. thanks sir..its very helpful..keep on posting these type of topics..

  2. This comment has been removed by the author.

  3. Nice explanation.... Worked well... Thanks...

  4. really nice 1 & easy language..., thanks a lot