Steps to create Web service:
1. Create a Web service application
2. In Solution Explorer, right-click the .asmx file and choose View Code.
3. Create a Web service method that does addition
[WebMethod]
public int WebAdd(int x, int y)
{
return x + y;
}
To call an XML Web service synchronously
1. Create a new Windows-based application
2. In Solution Explorer, right-click the References node of the project, and then click Add Web Reference. The Add Web Reference dialog box opens.
3. Type the following Web Service URI in the Address box
http://localhost/WebService1/Service1.asm[
^]
4. This is the URI of the Web Service you created in the previous procedure. The WebAdd and WebMultiply Web methods appear in the left pane of the Add Web Reference dialog box.
5.Add the code in Codebehind file
private void button1_Click(object sender, System.EventArgs e)
{
int x, y, z;
x = int.Parse(textBox1.Text);
y = int.Parse(textBox2.Text);
z = MathServiceClass.WebAdd(x, y);
textBox3.Text = z.ToString();
}
Run the application
Hope this helps.
Senthil S