1 首先用Vs.net建立WebService工程,添加以下调试代码
[WebMethod]public string HelloWorld() {
return "Hello World";
} [WebMethod]
public int Add(int x,int y)
{
return x + y;
}
2 新建VB工程,添加对soap toolkit的引用(Microsoft Soap Type Library 3.0)
3 在VB中添加以下代码:
Private Sub Command1_Click()
Dim soapClient As New SoapClient30
Dim text As String
'注:此为本地的WebService地址,实际应用中会有不同
soapClient.MSSoapInit "http://localhost:2239/DemoWebService/Service.asmx?WSDL"
text = soapClient.HelloWorld '此处直接写服务端方法名
MsgBox text
Dim total As Integer
total = soapClient.Add(2, 3)
MsgBox total
End Sub