CXF: generate the WSDL (convert) and cxfwerservice according to the werservice code.
Original article: http://hongyegu.iteye.com/blog/619147,thank you!
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;/*** constructor * @ param args the Java Class to generate the WSDL */public Java2WSDL (Class <?> ClassName) {this. className = className; // according to Hello. class generates Hello. the generated wsdl file is placed in the resource Directory args1 = new String [] {"-wsdl", "-d ",". /resource ", this. className. getName ()}; // according to Hello. class generates Hello. wsdl: The generated file is placed in the root directory. args2 = new String [] {"-wsdl", "-cp ",". /example ", this. className. getName ()}; // according to Hello. class generates the wsdl file named myHello. wsdl, in the root directory args3 = new String [] {"-o", "myHello. wsdl ","-wsdl ", this. className. g EtName () };}/*** constructor * @ param className the Java class to generate the WSDL * @ param wsdlFileName file name (excluding the extension) */public Java2WSDL (Class <?> ClassName, String wsdlFileName) {this. className = className; // generate Hello according to class. the generated wsdl file is placed in the resource Directory args1 = new String [] {"-wsdl", "-d ",". /resource ", this. className. getName ()}; // generate Hello according to class. wsdl: The generated file is placed in the root directory. args2 = new String [] {"-wsdl", "-cp ",". /example ", this. className. getName ()}; // generate the wsdl file based on the class, and name the file myHello. wsdl, which is placed in the root directory 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 );}}