How to consume a web service in ASP.NET

The technology .NET provides a solution with a dedicated component called a proxy class which wraps the calls to the web service’s methods. The class generates the correct SOAP message format and manages the transmission of the messages over the network by using HTTP. When it receives the response message, it converts the result back to the corresponding .NET data types.

The next picture presents this process:

 

The web service proxy class

The web service proxy class

Important notes:

1. Thanks to the proxy class, you can call a method in a web service as easily as you call a method in a local component, but you should keep in mind that web services have different characteristics than local components.

2. You should take into account the fact that every call needs to be converted to XML and sent over the network and it takes a nontrivial amount of time to call a web method.