建一个拓展名为:CMD的批处理文件。 内容如下:
set AXIS_HOME=E:\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 sturb http://localhost:8080/axis/Test.jws?wsdl
以上set 部分是设置环境变量 并且引入需要的jar包。
-p sturb 是生成的文件放入到 sturb目录中。
http://localhost:8080/axis/Test.jws?wsdl 是wsdl 也可以将该文件存储到本地 然后写入改文件的地址。
测试代码:
package sturb; import java.rmi.RemoteException; import javax.xml.rpc.ServiceException; public class Test { public static void main(String[] args) { TestService testService = new TestServiceLocator(); try { String name = testService.getTest().sayHello("aa"); System.out.println(name); } catch (RemoteException e) { e.printStackTrace(); } catch (ServiceException e) { e.printStackTrace(); } } }