Create a Simple Web Service and Use it in ASP.Net and Windows Form (Calculator)
A Web Service is a reusable piece of code used to communicate among Heterogeneous Applications.
Once a web service is created and hosted on the server in the internet it can be consumed by any kind of application developed in any technology.
- Step 1
Go to Visual Studio then click on "File" -> "Website" -> "ASP.NET empty website template".
Then provide the website name (for example: WebServiceSample).
- Step 2 Add a Web Service File
Go to Solution Explorer, then select the solution then click on "Add new item".
Enter the name (for example: CalcSrvice.asmx) then click on "Add".
- Step 3
To see whether the service is running correctly go to the Solution Explorer then open " CalcSrvice.asmx" and run your application. Now you will find all the method names in the browser
- Step 4 Creating the EndPoint application (Web or Applicatio Form) I will go with application form in this example
- Step 5 Add a web reference to the Website Go to Solution Explorer then select the solution then click on "AddWeb Reference" then within the URL type the service reference path.
- Step 6 You need to run both programms at the same time first run the service then run the application form