Web Service
1) create asp.net web application project and add webservice into the project
2) add this code to asmx.cs file of class library
public int add(int a, int b)
{
return a + b;
}
3)run and test it
4)add asp.net web application project to your solution
5)add reference of service to asp.net web application
6)add this code to aspx file
<table>
<tr>
<td>Enter Number 1</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Enter number 2</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="Button1" runat="server" Text="Add" OnClick="Button1_Click" /></td>
</tr>
</table>
7)add this code to aspx.cs file(double click on Add button)
addservice.WebService1SoapClient client = new addservice.WebService1SoapClient();
int result = client.add(Convert.ToInt32(TextBox1.Text), Convert.ToInt32(TextBox2.Text));
Response.Write(result);
8)set asp.net application as startup project
Comments
Post a Comment