Saturday, February 1, 2014

How to Create Web Service using C# (For Beginners)


 Creating Web Service in C# Step by Step manner (Use full for freshers)
  •   Create new project in Visual studio framework



  • Choose the visual studio 3.5 framework using C# programming language in Web Application Template Choose ASP.NET Web Service Application create new web service project.



















  • After Opening the solution the default web method "HELLO WORLD ()" in the Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace WebService1
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 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 Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

              
    }
}

  • Created custom method for getting input parameter in the below web method. In this below method i get  input string parameter.  
          [WebMethod]
        public string Welcome(string name)
        {
            return string.Format("Welcome {0} to Tutorial Web Service", name);
        }


  • After executing the Web Service Application the all methods displayed in the screen


  • Input Parameter method invoke Operation

  • After invoke Operation result of the web method the result will appear as below,




















I hope the above article will meet the expectation for simple Creating Web Service.