So I had to use Axis's ant tasks for wsdl2java. I did it like this:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<path id="compile_classpath" refid="maven.compile.classpath"/>
<taskdef resource="axis-tasks.properties" classpathref="compile_classpath" />
<property name="legacyService.wsdl" value="src/main/resources/ref-wsdl/legacy.wsdl"/>
<property name="newOne.wsdl" value="http://your.host/service.wsdl"/>
<property name="generated.dir" value="src/main/java"/>
<axis-wsdl2java output="${generated.dir}" verbose="true" url="${legacyService.wsdl}" >
<mapping namespace="urn:ServiceNameSpace" package="com.rst.webservice.legacy.client.axis14.util" />
</axis-wsdl2java>
<axis-wsdl2java output="${generated.dir}" verbose="true" url="${newOne.wsdl}" >
<mapping namespace="http://webservice.rst.com" package="com.rst.webservice.newone.client.axis14.util" />
</axis-wsdl2java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- ..... -->
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-ant</artifactId>
<version>1.4</version>
</dependency>
<!-- ..... -->
<dependencies>
Now, if you observe the above piece of pom.xml, axis:wsdl2java task is executed in 'generate-sources' phase, and Maven needs axis-ant.jar to execute that, but it is not available to Maven by default. So we need to provide Maven with this dependency.
How to provide this dependency to maven?
Now that's tricky, if you see the Documentation page about Maven Classpaths for ant-tasks then you would notice that the classpath that Maven refers to for executing various goals is not available as built-in variable. So I could have defined a path variable with hard-coded path to axis-ant.jar or I could define a 'dependency' to axis-ant and refer to maven.compile.classpath. And as you see I chose the second approach.
4 comments:
Hi Rushikesh,
I struggled a lot with the different wsdl2java maven plugins and faced similar problems like you. Finally with your advice I could manage to completly include my old ant tasks into maven.
For better separation between classpath and plugin dependencies I included the ant jar's right after the executions tag.
Bye
Sebastian
Hi Sebastian,
I'm glad it worked for you!
Thanks for acknowledging the same. Sorry for my delayed response. Your comment somehow went unnoticed.
Bye..
- Rushi
Hi Rushikesh,
In maven axis wsdl2java plugin is there a way to specify wsdl location as url. i mean not as a file in any project directoy but as url resource.
Thank you.
Hi Chakri,
I apologize for my late response. As I mentioned in my post I am specifying the location of WSDL as an HTTP URL:
<property name="newOne.wsdl" value="http://your.host/service.wsdl"/>
I guess that's what you want, right?
Post a Comment