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 System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using AjaxControlToolkit;
using System.ServiceModel.Web;
using System.Xml;
[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 CreatePOWS : System.Web.Services.WebService
{
public CreatePOWS()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
//If you want enable session and call this method in server side then uncomment the below line
//[System.Web.Services.WebMethod(EnableSession = true)]
//WebMethod used to call this method in client side
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
//After that create object for call webservice in serverside
CreatePOWS obj_CreatePOWS =new CreatePOWS ();
Response.Write(obj_CreatePOWS.HelloWorld());
//For ClientSide Call add the following lines inside the form
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
<Services>
<asp:ServiceReference Path="~/Service/CreatePOWS.asmx" />
</Services>
</asp:ScriptManager>
//then script call webservice methods through
alert(CreatePOWS.HelloWorld());
No comments:
Post a Comment