What is web service ?

Web Service

Web services are business logic components which provide functionality via the internet using standard protocols such as HTTP.

Web services uses simple Object access protocol (SOAP) in order to expose the business functionality. SOAP is the platform independent so consumer of web service can take service on any platform. i.e Unix,Linux etc.

Uses Of web service

It is used to communicate with different applications which has been developed on different platform using different technology.

How to Create Simple web service to fill GridView in Asp.net 3.5 ?

These are the following steps to create the web service

Step1. Add the web service file as shown in fig1

Step 2.  Write the following code in webservice.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Services;

using System.Data.SqlClient;

using System.Data;

/// <summary>

/// Summary description for WebService2

/// </summary>

[WebService(Namespace = “http://tempuri.org/&#8221;)]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

// [System.Web.Script.Services.ScriptService]

public class WebService2 : System.Web.Services.WebService {

public WebService2 () {

//Uncomment the following line if using designed components




public DataSet GetEmpName()


SqlConnection con = new SqlConnection(“Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database.mdf;Integrated Security=True;User Instance=True”);

SqlCommand cmd = new SqlCommand(“Select *from tblEmp”, con);

SqlDataAdapter da = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();


return ds;



Step 3: Compile the web service file as shown in fig2








Step 4:

Click on getEmpName method then Click on “Invoke” as shown in fig3. If the web service is correct then you will get the EmpName in Xml formate.

Then copy the webservice URL  I.e  http://localhost:1036/TestWebService/WebService2.asmx

Step 5: Go to Solution exp then select your project ->Right click on project -> add  web  reference. Then you get like this

Then you will get .disco and .wsdl file in Solution explore of project.

Step 6: Go to default page, Take a gridview control and write the following code in code behind file for filling the gridview Control.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page


protected void Page_Load(object sender, EventArgs e)




protected void fillgridview()


WsTest.WebService2 ws = new WsTest.WebService2();

GridView1.DataSource = ws.GetEmpName();





18 thoughts on “What is web service ?

  1. Amir September 8, 2010 / 11:22 am

    Dear chandra,

    Would you please send me source code of this sample.
    my email is : clickmeplz@ymail.com

    Thaks a lot

  2. ajay kumar June 22, 2011 / 11:05 am

    Hey this document is very helpful for me,,,,,

    • Chandra Dev June 22, 2011 / 12:29 pm

      I m really glad to hear that it helped you.Thank you for your comment.

  3. Religion And science July 16, 2013 / 1:38 am

    A person necessarily assist to make severely posts I’d state. This is the first time I frequented your website page and up to now? I surprised with the research you made to create this particular put up incredible. Excellent process!

  4. garcinia cambogia dosage for weight loss August 7, 2013 / 11:54 am

    Does your blog have a contact page? I’m having problems locating it but, I’d like to send you an email.
    I’ve got some recommendations for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it develop over time.

  5. deluxe February 1, 2014 / 8:15 pm

    I’m really enjoying the theme/design of your site.
    Do you ever run into any browser compatibility issues? A handful of my blog readers
    have complained about my blog not operating correctly
    in Explorer but looks great in Chrome. Do you have any suggestions to help fix this problem?

  6. letter April 27, 2014 / 9:43 am

    Hey there! I know this is kinda off topic however I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest writing a blog article
    or vice-versa? My website discusses a lot of the same subjects as
    yours and I think we could greatly benefit from each other.
    If you’re interested feel free to shoot me an e-mail.

    I look forward to hearing from you! Excellent blog by the way!

    • Chandra Dev May 1, 2014 / 4:31 am


      Could you please share your website URL ?

  7. cell April 27, 2014 / 10:45 pm

    Hello! Quick question that’s entirely off topic. Do you know how to
    make your site mobile friendly? My website looks weird when viewing from my apple iphone.
    I’m trying to find a template or plugin that might be able to resolve this issue.
    If you have any recommendations, please share.

  8. Wieńce June 5, 2014 / 5:14 pm

    Spot on with this write-up, I seriously think
    this site needs a lot more attention. I’ll probably be back again to
    read through more, thanks for the information!

  9. here June 10, 2014 / 6:00 am

    I have been browsing online greater tyan 3 hours nowadays, but I by no
    means discovered any fascinating article likke yours.
    It is lovely worth sufficient foor me. In my opinion, if all
    web owners and loggers made just rightt content
    as you did, the internet can be a lot more useful than ever before.

  10. lurlenedubay September 25, 2014 / 6:35 pm

    Article writing is also a fun, if you be familiar with after that you can write otherwise it is
    complicated to write.

  11. adelaidastephen October 10, 2014 / 1:36 pm

    You have made some good points there. I looked on the internet for more information about the issue and found
    most individuals will go along with your views on this site.

  12. Juan Lansden December 18, 2019 / 11:37 am

    Amazing blog! I Loved reading this article.

  13. Chad Eilert December 18, 2019 / 9:03 pm

    This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.

  14. Linnea Conaty December 19, 2019 / 4:18 am

    Amazing blog! I Loved reading this article.

  15. Junita Schwulst December 20, 2019 / 10:07 am

    there is no download link but it says Download latest release from GitHub then you press it and it wont let you save it or open and I really just want to know whats going on

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.