1,拷贝依赖包
axis-ant.jar
axis.jar
commons-discovery-0.2.jar
commons-logging-1.0.4.jar
jaxrpc.jar
log4j-1.2.8.jar
saaj.jar
wsdl4j-1.5.1.jar
2,把wsdl生成 Stub(存根)
使用一下 cmd命令
set AXIS_HOME=*\axis-1_4
set CLASSPATH=.;%AXIS_HOME%\lib\axis.jar;%AXIS_HOME%\lib\axis-ant.jar;%AXIS_HOME%\lib\commons-discovery-0.2.jar;%AXIS_HOME%\lib\commons-logging-1.0.4.jar;%AXIS_HOME%\lib\jaxrpc.jar;%AXIS_HOME%\lib\log4j-1.2.8.jar;%AXIS_HOME%\lib\saaj.jar;%AXIS_HOME%\lib\wsdl4j-1.5.1.jar
java org.apache.axis.wsdl.WSDL2Java -p com.chuangfuwu.ws http://localhost:9999/SSJS?wsdl
或使用下面这个
rem java org.apache.axis.wsdl.WSDL2Java -p com.bjpowernode.ssjs c:\MyMath.xml
在你的AXIS_HOME目录下会生成一个com文件夹 把他拷贝到你的项目中
写一个 Client类
package com.chuangfuwu.ws;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
public class Client {
public static void main(String[] args) {
MyMathService myMathService = new MyMathServiceLocator();
MyMath_PortType myMath_PortType;
try {
myMath_PortType = myMathService.getMyMath();
System.out.println(myMath_PortType.squared(6));
} catch (ServiceException | RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}