Imports System.Web.Services <System.Web.Services.WebService(Namespace :Namespace :="http://tempuri.org/VSService/Service1")> _ PublicClass Service1Class Service1 Inherits System.Web.Services.WebService #Region " Web Services Designer Generated Code " PublicSub New()SubNew() MyBase.New() 'This call is required by the Web Services Designer. InitializeComponent() 'Add your own initialization code after the InitializeComponent() call End Sub 'Required by the Web Services Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Web Services Designer 'It can be modified using the Web Services Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()>PrivateSub InitializeComponent()Sub InitializeComponent() components =New System.ComponentModel.Container() End Sub ProtectedOverloadsOverridesSub Dispose()Sub Dispose(ByVal disposing AsBoolean) 'CODEGEN: This procedure is required by the Web Services Designer 'Do not modify it using the code editor. If disposing Then IfNot (components IsNothing) Then components.Dispose() EndIf EndIf MyBase.Dispose(disposing) End Sub #End Region ' WEB SERVICE EXAMPLE ' The HelloWorld() example service returns the string Hello World. ' To build, uncomment the following lines then save and build the project. ' To test this web service, ensure that the .asmx file is the start page ' and press F5. ' '<WebMethod()> _ 'Public Function HelloWorld() As String ' Return "Hello World" 'End Function <WebMethod()>PublicFunction add()Function add(ByVal a AsInteger, ByVal b AsInteger) AsString add =CStr(a + b) End Function End Class
2. asp.net调用,添加Web References。
Dim s AsString Dim t AsNew mingservice.Service1 ResultAdd.Text = t.add(CInt(Param1.Text), CInt(Param2.Text))