Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 748
QAH Avatar asked Mar 07 '09 06:03

QAH


People also ask

Is RestSharp better than HttpClient?

The main conclusion is that one is not better than the other, and we shouldn't compare them since RestSharp is a wrapper around HttpClient.

What is IHttpActionResult C#?

IHttpActionResult contains a single method, ExecuteAsync, which asynchronously creates an HttpResponseMessage instance. C# Copy. public interface IHttpActionResult { Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken); }


1 Answers

  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.

like image 167
Andrew Arnott Avatar answered Oct 27 '22 01:10

Andrew Arnott