SIGN UP MEMBER LOGIN:    
ARTICLE

How to create Web Services in ASP.NET

Posted by Lion Articles | Web Services in C# November 19, 2010
In this article we will see how to create Web Services in ASP.NET.
Reader Level:
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();      
    }
}

Login to add your contents and source code to this article
share this article :
post comment
 

Can you please explain step by step, how to create Web service and how to the call the service in web page... -Thanks and regards, Selva selvamsc@gmail.com

Posted by Selva ganapathy Jun 24, 2011
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor