Assume that we've a web service @
http://localhost/websvc/strsvc.asmx. In order to add a web reference to this service the way you asked, you must follow the following steps:
1) Open Visual Studio.NET Command prompt.
2) Enter command: disco
http://localhost/websvc/strsvc.asmx /out:c:\websvc; Press enter. The disco.exe tool will generate some files that contain info about the web service in the specified directory (c:\websvc).
3) Enter command: wsdl c:\websvc\strsvc.wsdl /l:cs /o:c:\websvc\strsvc.cs; Press enter. The wsdl.exe tool will generate a C# source file containing the proxy class for the web service.
4) Create a new Windows Application project in Visual Studio.NET.
5) Add a reference to the assembly System.Web.Services.dll.
6) Right-click your project, select Add Existing Item, browse to c:\websvc and open strsvc.cs.
7) That's all! You've a web reference to your web service. Now you can create instances of your web service and invoke methods on it.
For detailed information on how the disco.exe and wsdl.exe tools work, please look into the .NET Framework SDK Documentation.
Regards,
ejan