Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more: , +
I have created an web service, through which i interact with database.

I have desktop application done in c#, and i want to call web method for insert,update,delete and selecting data using web service...


Please Help me....!!!
Posted

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

C#
[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

C#
private void button1_Click(object sender, System.EventArgs e)
{
// Create instances of the operands and result.
   int x, y, z;
// Parse the contents of the text boxes into integers.
   x = int.Parse(textBox1.Text);
   y = int.Parse(textBox2.Text);
// Call the WebAdd Web service method from the instance of the Web service.
   z = MathServiceClass.WebAdd(x, y);
   textBox3.Text = z.ToString();
}


Run the application

Hope this helps.

Senthil S
 
Share this answer
 
Just add service reference, and use the generated proxy class.

http://stackoverflow.com/questions/621440/calling-asp-net-web-service-from-c-application[^]
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900