1.根据wsdl生成客户端。
wsdl2java -p com.sf.module.webservice.addressbook.client -frontend jaxws21 -d d:\cxfoutput\src -all http://10.0.131.4:9002/DataExport.asmx?wsdl;
-p 指定其wsdl的命名空间,也就是要生成代码的包名:
-d 指定要产生代码所在目录
-client 生成客户端测试web service的代码
-server 生成服务器启动web service的代码
-impl 生成web service的实现代码
-ant 生成build.xml文件
-all 生成所有开始端点代码:types,service proxy,,service interface, server mainline, client mainline, implementation object, and an Ant build.xml file.
2.怎样测试客户端代码,就是如何实例化接口。
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(DataExportSoap.class);
factory.setAddress(addressBookSysUrl);
DataExportSoap dataExportSoap =(DataExportSoap)factory.create();
得到接口后,就可以调用其中的方法了。