Web Service in .NET C# / VB.Net

"WebMethod()" converts the functions in your application into web services


Example:

VB.Net:

<%@ WebService Language="VBScript" Class="LengthConvert" %>

Imports System
Imports System.Web.Services

Public Class LengthConvert :Inherits WebService
   Public Function KilometerToMeter(ByVal Kilometer As String) As String
         return (Kilometer * 1000)
         end function
end class


C#:

[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";
     }
}
Tags:
Hot on Web:


About author