Reader Level:
ARTICLE

How to create Web Services in ASP.NET

Posted by Gohil Jayendrasinh Articles | Web Services in C# November 19, 2010
In this article we will see how to create Web Services in ASP.NET.
  • 0
  • 0
  • 17698
Download Files:
 

1.gif

Your web services code.

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

namespace MyServices
{
    /// <summary>
    /// Summary description for MyServicesExample
    /// </summary>
    [WebService(Namespace = "http://MyServices.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 MyServicesExample : System.Web.Services.WebService
    {
        [WebMethod]
        public string GetMyname()
        {
            return "Hi ! My Name is Gohil Jayendra.";
        }
    }
}

Your web page code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NameInfo;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnname_Click(object sender, EventArgs e)
    {
        NameInfo.MyServicesExample example = new MyServicesExample();
        lblname.Text = example.GetMyname();      
    }
}

COMMENT USING

Trending up