| <%@ WebService Language="C#" Class="MyMath" %> using System.Web.Services; public class MyMath { [ WebMethod ] public int Add(int num1, int num2) { return num1+num2; } } |
| [C#] <%@ WebService Language="C#" Class="MyName.MyWebService,MyAssembly" %> [Visual Basic] <%@ WebService Language="VB" Class="MyName.MyWebService,MyAssembly" %> |
| [C#] <%@ WebService Language="C#" Class="Math" Debug=true%> using System.Web.Services; using System; [WebService(Namespace="http://www.contoso.com/")] public class Math { [ WebMethod ] public int Add(int num1, int num2) { return num1+num2; } } [Visual Basic] <%@ WebService Language="VB" Class="Math"%> Imports System.Web.Services Imports System <WebService(Namespace:="http://www.contoso.com/")> _ Public Class Math <WebMethod()> Public Function Add(num1 As Integer, num2 As Integer) As Integer Return num1 + num2 End Function End Class |
| [C#] <%@ WebService Language="C#" Class="Util" %> using System; using System.Web.Services; public class Util: WebService { [ WebMethod(Description="Returns the time as stored on the Server",EnableSession=false)] public string Time() { return Context.Timestamp.TimeOfDay.ToString(); } } [Visual Basic] <%@ WebService Language="VB" Class="Util" %> Imports System Imports System.Web.Services Public Class Util Inherits WebService <WebMethod(Description := "Returns the time as stored on the Server", _ EnableSession := False)> _ Public Function Time() As String Return Context.Timestamp.TimeOfDay.ToString() End Function End Class |
| [C#] <%@ WebService Language="C#" Class="Util" %> using System; using System.Web.Services; public class Util: WebService { public int Add(int a, int b) { return a + b; } [ WebMethod] public long Multiply(int a, int b) { return a * b; } } [Visual Basic] <%@ WebService Language="VB" Class="Util" %> Imports System Imports System.Web.Services Public Class Util Inherits WebService Public Function Add(a As Integer, b As Integer) As Integer Return a + b End Function < WebMethod()> _ Public Function Multiply(a As Integer, b As Integer) As Long Return a * b End Function End Class |