Practical 9 - Create a simple Web service get a GET and POST endpoint for greetings
Create New WebSite Project in Visual Studio. Right click on the Solution explorer and Add New Item and Choose Web Service and save file. Write the following code in the file created and run it to test.
Webservice.cs
Webservice.cs
- using System;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.Services;
- ///<summary>
- /// Summary description for UtilityWebService
- ///</summary>
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
- // [System.Web.Script.Services.ScriptService]
- public class WebService: System.Web.Services.WebService
- {
- public WebService()
- {
- //Uncomment the following line if using designed components
- //InitializeComponent();
- }
- [WebMethod]
- public string greetings(string name)
- {
- return "Greetings of the day, " + name + "!";
- }
- }
Comments
Post a Comment
Post Your Valuable Comments