Friday, 8 November 2013

Creating a Web Service in .NET | SOA Lab Manual




SOURCE CODE:
Service.cs
using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
public class Service : System.Web.Services.WebService
{
    public Service ()
    {}
    [WebMethod]
    public int add(int a, int b)
    {
        return a + b;
    }
    [WebMethod]
    public int sub(int a, int b)
    {
        return a - b;
    }
    [WebMethod]
    public int mul(int a, int b)
    {
        return a * b;
    }
    [WebMethod]
    public int div(int a, int b)
    {
        return a / b;
    }
   
}




Default.asp.cs
Top of Form
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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
{  localhost.Service cal = new localhost.Service();
     protected void Button1_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.add(a, b);
        TextBox3.Text = c.ToString(); 
    }
    protected void Button2_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.sub(a, b);
        TextBox3.Text = c.ToString();
    }
 protected void Button3_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.mul(a, b);
        TextBox3.Text = c.ToString();
    }
 protected void Button4_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.div(a, b);
        TextBox3.Text = c.ToString();
    }



}




No comments:

Don't You Think this Awesome Post should be shared ??
| Creating a Web Service in .NET | SOA Lab Manual |
Back To Top Related Posts Plugin for WordPress, Blogger...