Please follow this link to get additional information about the web service from Wikipidia.
What is a web service in the context of ASP.NET? A web service can be considered as a remote software component. In this case, the component that resides in a hosting server offers functionalities that can be consumed by any application remotely via the internet.
CREATING A WEB SERVICE FILE
In ASP.NET, we can create a web service file with the extension ".asmx". We can use any of the .NET supported languages to write the codes. However, it is recommended to use C# programming language due to its efficiency and strong type support.
The picture below shows an example of a web service file.
As you can see from the picture, the web service file (asmx) has a page directive such as
<% @ WebService Language="VB" class="TestWS" %>
Every method that you want to expose as a web method must be declared with the webmethod attribute and public access modifier. Once a method is declared as a web method, it can be called remotely by any other application via the web/internet.
Since the web service is using HTTP, it must be placed in a web application folder of the web server. This works almost similar to the ordinary web application.
CONSUMING THE WEB SERVICE
To consume a web method in the web service file, we must first create a proxy file in our machine using the WSDL tool that comes with Visual Studio. The following is an example how to use the WSDL command-line tool to create the proxy file (note that D:\webservice> is the DOS command prompt where you type the command -- D:\ is the drive and webservice is the folder name),
D:\webservice>wsdl http://www.wakiltakaful.com/mywebservice/testws_vb.asmx
/language:vb /namespace:safuan
In this case, the default output file that is created will be named TestWS.vb and the content is as shown as in the picture below.
Now we can use the VB command-line compiler to compile the proxy file to an assembly as shown below:
D:\webservice>vbc testws.vb /target:library
The output file will be testws.dll.
Once you have the assembly, you may make reference to it in your winform or webform application. If you use Visual Studio, the assembly will be copied locally in the bin folder of the application folder.
The picture below shows how the proxy is added to a web application folder.
Remember that the assembly only contains the definition not the actual program logics. The program logics is in the web service file located in the remote server. In other words, you still must have a working internet in order to use the web methods.