This blog explains basic knowledge abut how to create and use web services.
Create WebService
- Open Visual Studio 2010
- Click on New project Link on start page
- New Project Window Will Open
- Select Asp.net Web Application in the template window
- Enter the name of project
- Click on ok button
- Open Solution Explorer of your project
- Right click on project, the pop window will open
- Drag cursor on to add menu, the submenu of add menu will open, click on NewItem or Go to Add->NewItem.
- The AddNew Item Window will open, Select WebService and Rename WebService1.asmx to MyWebService.asmx, then click on ok button.
- The MyWebService.asmx file will appear in the solution explorer, open MyWebService.asmx file
- Declare your own method in this file
bellow the HellowWorld function. You can remove the HellowWorld function
from the WebService.
For Example : the bellow function generate a random number and returns to it.
[WebMethod(Description = "Get Random Number")]//Description about web method
public string GetNumber() // Declaration of Method
{
Random RM=new Random();
return RM.Next(1,100).ToString();
}
[WebMethod(Description = "Adds Two Number And return result")]
public string Add(int firstno, int secondno)
{
double result = firstno + secondno;
return result.ToString();
}
This is the all about create web service in your project, and then we will discuss about how to use or consume web service in your application.
bava palaniPosted Mar 19, 2019, 4:15 AM
Hai.....that's amazing job.........thank you so much.....
chan chanPosted Oct 12, 2018, 2:15 AM
Hi nice details provided. I am using .net3.5 in VS2012 and created simple web services and I am facing "HTTP Error 404.3 - Not Found" error while trying to open from IIS. I need to host it in IIS and access it from anywhere within the network, but I am unable to resolve. Could you please help me in resolving this issue, Please. My contact is [email protected]. just needs solutions for hosting a webservice in IIS. I have tried all possibilities
Vittorio MorelliniPosted May 23, 2016, 8:21 AM
I have no need to create a multitasking web service, IIS will manage multitasking request on a web service. Asmx is the best way in VS2010 ?
Vittorio MorelliniPosted May 23, 2016, 8:19 AM
Is this the Best way to create a Web Service multitasking ? via VS2010 ? or Web Api pattern is better ? is it available in VS2010 ?
JohnPosted Jan 15, 2016, 11:39 PM
I wanted to know how to send bulk data to web service using json
Muhammad Ashikuzzaman AshikPosted Oct 11, 2015, 8:34 AM
Thank you very much. I was confused I was surmising that I may have to set up another .exe file to get web service like WCF in visual studio 2010.
Nahed DaberhaPosted Sep 10, 2015, 1:29 PM
Thank you
kunedo kunedoPosted May 27, 2015, 5:27 PM
Thanks you for the help
kushan fernandoPosted Mar 25, 2015, 8:30 AM
Thank you for the simple and easy example.
Rich KeslarPosted Jan 23, 2015, 12:22 PM
Thanks, that was a good example. I was able to get it working.
Narasimhan RamaniPosted Sep 22, 2014, 3:26 AM
Thanks
s vPosted Oct 30, 2013, 1:22 PM
Thanks for this usefull tutorial