Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
what are the benefits of using service pages in asp.net projects
C#
using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using BusinessLogic.BLL;
using System.Text.RegularExpressions;
using DataAccess.DL;
using System.Collections.Generic;
using System.Web.Script.Services;
using System.Data;

namespace TravelAgency.Services
{
    /// <summary>
    /// Summary description for User
    /// </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 User : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod(EnableSession = true)]
        public string RegisterUser(string Title, string First_Name, string Last_Name, string Email, string Ref_No, DateTime ADate, string ATime, DateTime DDate, string DTime, int N_F_Nights, string Room_Type, int N_F_Rooms, int N_F_Adults, int N_F_Child, string Booking_Terms, float Amount)
        {
            BLLRegister objBLL = new BLLRegister();
            DLRegister objDL = new DLRegister();

            string res = "";

            objDL.TA_Title = Title.ToString().Trim();
            objDL.TA_Fname = First_Name.ToString().Trim();
            objDL.TA_Lname = Last_Name.ToString().Trim();
            objDL.TA_Email = Email.Trim();
            objDL.TA_BookingRefNo = Ref_No.ToString().Trim();
            objDL.TA_ArrivalDate = Convert.ToDateTime(ADate);
            objDL.TA_DepDate = Convert.ToDateTime(DDate);
            objDL.TA_Nights = Convert.ToInt32(N_F_Nights);
            objDL.TA_RoomType = Room_Type.ToString().Trim();
            objDL.TA_Rooms = Convert.ToInt32(N_F_Rooms);
            objDL.TA_Adults = Convert.ToInt32(N_F_Adults);
            objDL.TA_Child = Convert.ToInt32(N_F_Child);
            objDL.TA_BookingTerms = Booking_Terms.ToString().Trim();
            objDL.TA_AmountDue = Convert.ToInt32(Amount);



            if (objBLL.RegisterUser(objDL))
            {



              


                res = "Success";


            }
            else
            {
                res = "Failed";
            }
            return res;
        }

    }
}
Posted
Updated 26-Feb-14 0:38am
v3
Comments
samit kaneriya 26-Feb-14 6:42am    
Reduce page life cycle and you can get or post data by use of javascript in client side
Tifna Joseph 26-Feb-14 6:57am    
that means by using webservice we can get fast rendering. right?

 
Share this answer
 
Comments
Tifna Joseph 26-Feb-14 6:56am    
can anyone explain why we are using webservice pages. what are the uses of webpages? we can do the above mentioned coding in code behind also.
Web Services provide a channel through which servers or different type of applications talk to eachother. Suppose you want to provide some sort of service from your application to some other application and you want to hide your logic and implementation etc, so you just provide a Web Service and others would consume and get the result.

For instance, take example of a Web Service which would give you your call details from a Telecom Operator. So, they are not going to show or allow you to connect to their database.

Instead, they would give you a Service URL, you will just call the required method in that Service and get the data and show in your application.

Refer - [^]
Web service[^]
From wiki:
A Web service is a method of communications between two electronic devices over the World Wide Web. It is a software function provided at a network address over the web with the service always on as in the concept of utility computing.
Google for more.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900