


A Simple Example To run a WebServices :
=====================================================================================
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
[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 Factorial : System.Web.Services.WebService
{
public Factorial()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public int FindFact(int x)
{
int a=1;
while (x != 0)
{
a = a * x;
x--;
}
return a;
}
}
=================================================================================
Client Program :
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnClick_Click(object sender, EventArgs e)
{
Factorial Fct = new Factorial();
int Res = Fct.FindFact(Convert.ToInt32(txtFact.Text));
txtShowFact.Text = Convert.ToString(Res);
}
}
===========================================================================
Output:
==============================================================================