CXF:根据werservice代码生成WSDL(转)
原文:http://hongyegu.iteye.com/blog/619147,谢谢!
import org.apache.cxf.tools.java2ws.JavaToWS; import net.bwda.service.Busi.webservice.FileMarkService; public class Java2WSDL { private Class<?> className; public String[] args1,args2,args3; /** * 构造函数 * @param args 要生成WSDL的Java类 */ public Java2WSDL(Class<?> className) { this.className = className; //根据Hello.class生成Hello.wsdl,生成的wsdl文件放在resource目录下 args1=new String[]{"-wsdl","-d","./resource",this.className.getName()}; //根据Hello.class生成Hello.wsdl,生成的文件放在根目录下的.example下 args2=new String[]{"-wsdl","-cp", "./example",this.className.getName()}; // 根据Hello.class生成wsdl文件,文件命名为myHello.wsdl,放在根目录下 args3=new String[]{"-o","myHello.wsdl","-wsdl",this.className.getName()}; } /** * 构造函数 * @param className 要生成WSDL的Java类 * @param wsdlFileName 要生成WSDL的文件名称(不包含扩展名) */ public Java2WSDL(Class<?> className,String wsdlFileName) { this.className = className; //根据class生成Hello.wsdl,生成的wsdl文件放在resource目录下 args1=new String[]{"-wsdl","-d","./resource",this.className.getName()}; //根据class生成Hello.wsdl,生成的文件放在根目录下的.example下 args2=new String[]{"-wsdl","-cp", "./example",this.className.getName()}; // 根据class生成wsdl文件,文件命名为myHello.wsdl,放在根目录下 args3=new String[]{"-o",wsdlFileName+".wsdl","-wsdl",this.className.getName()}; } public void java2WSDL(String[] args){ JavaToWS javaToWS = new JavaToWS(args); try { javaToWS.run(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { Java2WSDL java2WSDL = new Java2WSDL(FileMarkService.class); java2WSDL.java2WSDL(java2WSDL.args1); } }
相关推荐
Lzs 2020-10-23
聚合室 2020-11-16
零 2020-09-18
Justhavefun 2020-10-22
jacktangj 2020-10-14
ChaITSimpleLove 2020-10-06
Andrea0 2020-09-18
周游列国之仕子 2020-09-15
afanti 2020-09-16
88234852 2020-09-15
YClimb 2020-09-15
风雨断肠人 2020-09-04
卖口粥湛蓝的天空 2020-09-15
stulen 2020-09-15
pythonxuexi 2020-09-06
abfdada 2020-08-26
梦的天空 2020-08-25