Introduction:
Here I am creating a web service for a login check and consuming it in a web
application. Follow the given steps to do it.
Step1: Create a web service using the following steps.
- Go to Visual Studeo 2010 and take a New Project.
- Select .NET Framework 3.5.
- Take a ASP.NET Web Service Application.
- Give it a name and click ok button.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;
namespace loginwebservice
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 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 Service1 : System.Web.Services.WebService
{
[WebMethod]
public DataSet login(string uname, string pwd)
{
SqlDataAdapter da = new SqlDataAdapter("select * from login where user_name ='" + uname + "' and password='" + pwd + "' ",
@"DataSource=SERVER_NAME;Initial Catalog=EMP;Integrated Security=True");
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
}
}
Step 3: Run this application.
Output:
Step 4: Now create a web application to consume the service. For doing this, follow the given steps.




varun chinnaPosted Dec 2, 2015, 5:14 AM
how to consume a Web service in Windows Mobile Application.
Pintoo YadavPosted Sep 30, 2015, 7:43 AM
good one
ketan italiyaPosted Aug 23, 2013, 8:21 AM
so helpful..thankss
surya kumarPosted Apr 3, 2013, 8:39 AM
Easy to Understand..Nice work
Mohamad AhmadPosted Jul 3, 2012, 6:52 AM
Thanks, Good Work.
Manoj Singh PanwarPosted Nov 23, 2011, 4:18 PM
Its really nice to know that web services can be used for Log in page also. Thank you for exploring this concept Alok.