CXF: generate the WSDL and cxfwerservice according to the werservice code.

Source: Internet
Author: User

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 );}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.