ASP.NET web services

From Logic Wiki
Jump to: navigation, search


To make a method, WebMethod add this keyword to the beginning of method

[WebMethod]
public int AddUser(string name)
{
....
}

To Add a description to a method

[WebMethod(Description = "Adds a user to the system")

not necessary but inheriting WebService in main class is useful

public class MyWebService : WebService


using Ststem.Web.Services;
namespace MyWebServices
{
  [WebService(Namespace = "http://s3k.me")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [System.ComponentModel.ToolboxItem(false)]
  public class MyWebService : WebService
  {
    [WebMethod(Description = "Adds User")]
    public int AddUser(string Name)
    {
    ....
    }
  }
}

To use session in a web service method

[WebMethod(Description = "Adds a user to the system", EnableSession = true)

There is also a command line program to get wsdl info. (Check MSDN for parameters)

wsdl