Hello axis and maven users, Sorry to double post, but I have been struggling for some days with maven2 and axis2 code generation for a web service implementation and sometimes I don't know where to ask questions. Maybe you could excuse my double posting since I am not making a question, but explaining a solution for my problem.
I want to make a maven project for a webservice implementation using axis2. It has been very hard because I need to use the xmlbeans databinding and the maven plugins don't work for me in this case. I found a great solution for a multi module project that generates an aar artifact of a webservice, when another project uses this aar artifact. See http://stackoverflow.com/questions/73491 However, this did not work completely for me because: 1. I need the java2wsdl to generate xmlbeans stub classes. Easy to do when using wsdl2java, but when using the axis2-wsdl2code-maven-plugin it is not possible 2. Because of reason 1, I need to generate xmlbeans classes for xsd and wsdl files. The xmlbeans-maven-plugin has a known bug that cannot generate classes for wsdl. It is fixed but not patched to the trunk. 3. I do not want to generate sources every time I compile the project. I just need to run the generate-sources phase once. So I managed to solve my problem with the pom.xml below. This pom only generates an aar file that I was able to hot-deploy to an axis2 server. I don't have the parent pom yet nor the module that packs the aar file in a war, but it's a good start. I just hope it is useful for someone else in the future. Also if anyone wants to take a look and tell me if there is something wrong with it, please tell me. Thanks, pom.xml: <?xml version="1.0"?> <!-- Project for web service aar generation using axis2 and xmlbeans databinding Author: David Ojeda dojeda /at/ integra.la Date: 20081105 --> <project> <parent> <artifactId>ws-parent</artifactId> <groupId>my.group</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>my.group</groupId> <artifactId>ws-aar</artifactId> <packaging>aar</packaging> <name>ws-aar</name> <version>0.0.1-SNAPSHOT</version> <url>http://example.org</url> <profiles> <!-- Profile for axis and xmlbeans source generation. It will activate if the directory target/generated-sources does not exist. Therefore, it will only run once or every time a clean is made. --> <profile> <id>sourcegen</id> <activation> <activeByDefault>false</activeByDefault> <file> <missing>target/generated-sources</missing> </file> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> <executions> <!-- Execution for generating the xmlbeans classes and .xsb It is used instead of xmlbeans-maven-plugin because this plugin does not support wsdl files. See http://jira.codehaus.org/browse/MXMLBEANS-42 --> <execution> <id>xmlbeans-source-code-generation </id> <phase>generate-sources</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler" fork="true"> <arg line=" -javasource 1.5 -srconly -src target/generated-sources/xmlbeans -d target/generated-sources/xmlbeans src/main/wsdl src/main/xsd src/main/xsd/NStoPkg.xsdconfig" /> <classpath refid="maven.dependency.classpath" /> <classpath refid="maven.compile.classpath" /> <classpath refid="maven.runtime.classpath" /> </java> </tasks> </configuration> </execution> <!-- Execution for generation the axis service side classes. It is used instead of axis2-wsdl2code-maven-plugin because this plugins does not have all the command line options (such as -Ewdc). After code generation, the developer must copy the service implementation classes in target/generated-sources/axis2/ to src/main/java. Usually it is every class that does not extends org.apache.xmlbeans.XmlObject i.e. Skeleton, MessageReceiver, Faults. The developer may not want to copy these files if he/she already has a copy in src/main/java. It would be a nice feature to copy them automatically if they do not exist but the "everything that does not extend XmlObject" part seems difficult --> <execution> <id>axis2-source-code-generation</id> <phase>generate-sources</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> <!-- the WSDL file should be defined in the arg line --> <arg line=" -o target/generated-sources/axis2/ -ss -sd -d xmlbeans -Ewdc --noBuildXML -uri src/main/wsdl/WSSomeService.wsdl" /> <classpath refid="maven.dependency.classpath" /> <classpath refid="maven.compile.classpath" /> <classpath refid="maven.runtime.classpath" /> </java> </tasks> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.2</version> <!-- Execution that adds the directory target/generated-sources/xmlbeans as a source directory. It contains the generated classes of xmlbeans --> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>target/generated-sources/xmlbeans </source> </sources> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.axis2</groupId> <artifactId> axis2-aar-maven-plugin</artifactId> <version>1.4.1</version> <extensions>true</extensions> <configuration> <!-- This fileset includes the services.xml, wsdl and xsd that were used when generating axis and xmlbeans classes. This must be included in the aar in order to obtain the wsdl and xsd. Also, services.xml should be included or else axis2 will not deploy the webservice. The schemaorg_apache_xmlbeans directory is excluded since we need the one generated by xmlbeans and not by axis2. --> <fileSets> <fileSet> <directory>target/generated-sources/axis2/resources </directory> <outputDirectory>META-INF</outputDirectory> <includes> <include>*.xml</include> <include>*.xsd</include> <include>*.wsdl</include> </includes> <excludes> <exclude>schemaorg_apache_xmlbeans/**/* </exclude> </excludes> </fileSet> </fileSets> </configuration> </plugin> </plugins> </build> <!-- Most, if not all, axis2 dependencies are under the 'provided' scope since we do not want to have huge aar files. A dependant project should use this project artifact to build a war, the dependant project should include the axis2 jars in its WEB-INF/lib --> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2</artifactId> <version>1.4.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-java2wsdl</artifactId> <version>1.4.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2-xmlbeans</artifactId> <version>1.4.1</version> <scope>provided</scope> </dependency> </dependencies> </project> -- David Ojeda --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]