I am just wondering in how to use Web Services with class object .I have class object in my BOL like Customer, Task, Project and etc. I use ADO.net to connect to data layer I'm just start using Web services on my project I added folder called "WebServices"and I used the method on BOL to get data and fetch data to Json object in Web Services. I'm just wondering should I connect the WebServices directly to database or use BAL to get the data after that fetch it to Json .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Compudata_ProjectManager.CodeFile.BOL;
using System.Web.Script.Services;
namespace Compudata_ProjectManager.WebServices
{
/// <summary>
/// Summary description for CustomerList
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[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 CustomerList : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Customer> FetchCustomersList(string name)
{
var cust = new Customer();
var fetchNames = cust.GetAllCustomerNames().Where(n => n.FirstName.ToLower().StartsWith(name.ToLower()));
return fetchNames.ToList();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Location> FetchCustomerAddressList(string name)
{
var Addresses = new Location();
var fetchAddress = Location.GetAllAddress();
return fetchAddress.ToList();
}
}
}