2 Replies Latest reply on Dec 6, 2012 10:54 AM by Nasir Imtiaz

    Apache CXF support for XJC

    Nasir Imtiaz Newbie

      Hi,

       

      I was using Metro for my application but later when i migrated to JBoss 7 AS (which has completely dropped its support for Metro), so i had to switch to Apache CXF (the one which comes as a default webservice stack with JBoss 7 AS).

      Now, while generating my code through WSDL file using Metro i used to pass some extra xjc arguments to wsimport in order to generate a toString() method as well as some utility methods. The xjc arguments that i used are as follows:

       

      <xjcarg value="-Xcommons-lang"/>
      <xjcarg value="-Xcommons-lang:ToStringStyle=SHORT_PREFIX_STYLE" />
      <xjcarg value="-Xfluent-api"/>
      <xjcarg value="-Xcollection-setter-injector"/>
      

       

      I would like to do the same using Apache CXF but cant find any helpful resource online. So my requirement is to create an ANT script (not maven) to generate code using Apache CXF with above mentioned XJC arguments.

       

      Would appreciate your help.

        • 1. Re: Apache CXF support for XJC
          Alessio Soldano Master

          You can make direct use of Apache CXF wsdl2java tool, http://cxf.apache.org/docs/wsdl-to-java.html

          • 2. Re: Apache CXF support for XJC
            Nasir Imtiaz Newbie

            Thanks Alessio, i managed to do so by adding following libraries under %CXF_HOME%\lib directory:

             

            collection-setter-injector-1.0.jar
            jaxb-commons-lang-plugin-2.2.jar
            jaxb-fluent-api-2.2.jar
            

             

            Following is my ant build script snippet:

             

            <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true" failonerror="true">
             <arg value="-ant" />
             <arg value="-client" />
             <arg value="-d" />
             <arg value="${src}" />
             <arg value="-b" />
             <arg value="myBindingFile.xml" />
             <arg value="-xjc-Xcommons-lang"/>
             <arg value="-xjc-Xcommons-lang:ToStringStyle=SHORT_PREFIX_STYLE" />
             <arg value="-xjc-Xfluent-api" />
             <arg value="-xjc-Xcollection-setter-injector"/>
             <arg value="${wsdlUrl}" />
             <classpath>
              <fileset dir="${cxf.lib}">
               <include name="**/*.jar" />
              </fileset>
             </classpath>
            </java>