What is Webservices and how it works

This article gives an introductionto webservices and explains how it works.

Webservices is mainly used for accessing methods in a remote server. and it is based on SOAP protocol for communicating between the server and client.

In a remote server there will be some public webmethods.

Similar to the webservice in the remote server, there will proxy client file in the clinet site.

Whenever the request is made to the server for a method, proxy client will be checking all the inputs are correct ie the arguments are right and the argument types are right ...etc.

If any input is wrong, the proxy client will be intimating the error to the client.

If the input is correct, proxy client will convert it into xml format and send to the server through SOAP protocol.

In the server side, these input are taken and process the requested methods and send the results to the proxy client in the same format XML through SOAP protocole.

In the proxy client, it will parse the XML content and extract the result and send to the client.

This how basically Webservices are working.

The extension for webservice is asmx.

The following example shows a very simple .asmx file.

<%@ WebService Language="C#" Class="HelloWorld" %>

using System;
using System.Web.Services;

public class HelloWorld : WebService {

[WebMethod] public String SayHello(string name) {
return "Hello " + name;


We can make the proxy client through the command wsdl

eg :- WSDL http://someDomain.com/someFolder/Hello.asmx?WSDL to create a proxy class called Hello.cs.

Compile this proxy client file and put it in the bin folder of your application and add references to it.

In the client file we can access the Webservice webmethods through the following way

Hello hl=new Hello();

The out put will be "Hello Siju".

I hope you unserstand how to create webservice and how it is executing.


Author: Bhasker Das24 Jul 2004 Member Level: Bronze   Points : 0

Hi to all,
How we can use a WebService which is in another server? I have added a reference using "Add Web Reference .." through solution explorer and added successfully a web reference in my client machine and now usinig its class. The code i have used for that ...
WebReference.Service1 s = new WebReference.Service1();

It works fine .. but i get from some articles, that it is must to creat a proxy class to use a web service. Here i added only a web reference not adding much more, not creating a proxy class and it works fine too. Is it a second method to use a web service..
Let me clear about how is it working.

Author: Siju.C24 Jul 2004 Member Level: Silver   Points : 0

By add webreference it is creating the proxy file.

Author: Bhasker Das24 Jul 2004 Member Level: Bronze   Points : 0

Thanks Siju.C for quick reply, but i think i have already written that what i am doing to use web service. I am doing the same.

It means whenever we are adding a webrefernece to our application .. it creats a proxy class autometically?

Thanks for reply.

Author: Phagu Mahato02 Mar 2014 Member Level: Gold   Points : 1

You ca use below example code for Web.Config


Author: Umesh Bhosale14 Apr 2014 Member Level: Silver   Points : 3

Hello All
It is good practice to use Web Service
I have one suggestion is that whenever you return data in the form of DataSet then some time firewall oppose it so convert dataset into XmlDocuments and return back.

XmlDocument xml=null;
datatable dt=getData(1);
xml = new XmlDocument();

catch (SoapException sox)
throw sox;
return xml;


Author: Sridhar Thota26 Jun 2015 Member Level: Gold   Points : 8

Webservice is a class, managed by webserver.
With help of proxy class it calls the service methods.
Im simple we can say a piece of logic shared in a network is Webservice.
Webservice works on the below standard protocols.

It is a xml based language for providing complete description of webservice to client application.
Description contains which data types used,
method names and address in webservice.

Simple object access protocol is the formatting
protocol which provides standards for sending
request and receiving response between client and

Hyper text transfer protocol is used as a
transport to carry request in form of soap
message from client to webserver and response
from webserver to client.

Universal description discovery and integration is
used for describing the services and is platform

Mechanism of HTTP, SOAP in webservice:
1.Client application method call will go to proxy,
proxy will convert method call to xml format that
is soap message.
2.Soap message will reach webserver via HTTP
3.Webserver will create object of webservice and
method is executed.
4.The result in the form of soap format is given to
client back over HTTP.
The methods present in webservice which are to
be exposed to client application are attributed
with webmethod.
Ex: [webmethod]
Public void mymethod()
//some logic.


Sridhar Thota.
DNS Member.
"Hope for the best.. Prepare for the worst.."

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: