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

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Web;  
  4. using System.Web.Services;  
  5. ///<summary>  
  6. /// Summary description for UtilityWebService  
  7. ///</summary>  
  8. [WebService(Namespace = "http://tempuri.org/")]  
  9. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
  10. // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.   
  11. // [System.Web.Script.Services.ScriptService]  
  12. public class WebService: System.Web.Services.WebService   
  13. {  
  14.     public WebService()   
  15.     {  
  16.         //Uncomment the following line if using designed components   
  17.         //InitializeComponent();   
  18.     }  
  19.     [WebMethod]  
  20.     public string greetings(string name)  
  21.     {  
  22.         return "Greetings of the day, " + name + "!";  
  23.     }  
  24.   
  25. }

Comments

Popular posts from this blog

Zeller's Congruence

Property Event-Delegation

Method with variable arguments