我们以Java为例
在Tomcat部署WebService
先写一个JAVA文件
import java.util.*;
public class TestList{
public ArrayList Lists()
{
ArrayList list=new ArrayList();
list.add(0,"0");
list.add(1,"这是正确的信息");
list.add(2,new Date());
return list;
}
}
然后改后缀为jws,放置到axis目录下
确保这样可以访问http://localhost:8080/axis/TestList.jws?wsdl
之后,我们用VB6来调用
在Tomcat部署WebService
先写一个JAVA文件
import java.util.*;
public class TestList{
public ArrayList Lists()
{
ArrayList list=new ArrayList();
list.add(0,"0");
list.add(1,"这是正确的信息");
list.add(2,new Date());
return list;
}
}
然后改后缀为jws,放置到axis目录下
确保这样可以访问http://localhost:8080/axis/TestList.jws?wsdl
之后,我们用VB6来调用
'我们首先需要安装microsoft SoapToolkit30
'然后我们引用microsoft soap type library v3.0
'函数原型
'Mssoapinit(bstrWSDLFile as string,[bStrServiceName as string ],[bStrport as string ] ,[bstrWSMLDile as string])的用法:
'其中第二个,第三个参数在wsdl文件中可以找到。也可以省略。Private Sub Command2_Click()
On Error Resume Next
'利用变体数组模拟list,利用soap组件调用
Dim objSoapClient As New SoapClient30
Call objSoapClient.MSSoapInit("http://localhost:8080/axis/TestList.jws?wsdl", "TestListService", "TestList")
If Err.Number <> 0 Then
MsgBox SoapClient.FaultString, vbExclamation
Exit Sub
End If
Dim MyArr() As Variant
MyVar = objSoapClient.Lists()
MsgBox MyVar(0) & MyVar(1) & MyVar(2)
End Sub
好了。