QAH
QAH

Reputation: 4216

Calling ASP.net Web Service from C# Application

I have a question. How can i invoke a web service and get the result from a C# desktop application. I am making a desktop app and I want it to be able to connect to my online ASP.net web services. How is this possible?

Upvotes: 9

Views: 28834

Answers (4)

Rashedul.Rubel
Rashedul.Rubel

Reputation: 3584

Will get help how to create a webservice and consume that service:

http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-web-service-in-Asp-Net-web-application/

Thanks

Upvotes: 0

Andrew Arnott
Andrew Arnott

Reputation: 81821

  1. In Solution Explorer, right-click your project node and select Add Service Reference.
  2. Enter the URL where your service WSDL is located. This is usually the URL of the service itself.
  3. This generates a strongly-typed proxy class in a new Services References folder in your project.
  4. Write code in your desktop app to instantiate the proxy class and invoke methods on it. The rest works like magic. :)

AB Kolan was also correct, but Add Web Reference uses the old-style web services framework whereas Add Service References uses the new WCF stack. Important note: It is not required that the service itself use WCF for you to use WCF on the client side. WCF on the client is typically the best choice for any service, provided you can take a dependency on .NET 3.0 and above.

Upvotes: 9

abhilash
abhilash

Reputation: 5651

Add a Web Reference to the webservice in your Desktop App project reference. Doing so would generate a Proxy for the Webservice called Reference.cs You can access your webservice using the proxy.

Upvotes: 5

Cerebrus
Cerebrus

Reputation: 25775

This is possible the same way that you access web services from any other type of application, be it an ASP.NET page, a class library or windows service.

For an explanatory tutorial on the subject, see Accessing a Web Service from a Desktop Application.

Upvotes: 1

Related Questions