Reputation: 9162
I've got an axis2 web-service generated from the WSDL file in a multi module maven project.
wsdl2java
has generated the stubs and basic skeleton for me.
What's the best way to integrate those generated stubs into the exsisting business logic?
I've got several considerations:
mvn clean install
command. Maven clean
deletes the generated source folder. I will have to protect the stub with the implemented business logic from deletion.services.xml
(and that's generated with maven-axis2 plugin). So again some parts of the generated stubs should be protected from modification.Is there a way to somehow avoid this? Something like specifying the service class implementation in the web.xml? or anything similar?
Upvotes: 1
Views: 1776
Reputation: 1520
What you have to do it is to configure maven pom, in order to let maven does the work.
First of all you configure a maven properties, let's call it outputDirectory
, the folder should be located inside the maven target folder, which I usually don't commit in the SCM.
Then you have to configure Axis maven plugin in order to generate stub sources into the target folder, as follow
<build>
<plugins>
...
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
... your configuration ..
<generateServerSide>true</generateServerSide>
<generateServerSideInterface>true</generateServerSideInterface>
<outputDirectory>${outputDirectory}</outputDirectory>
...
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
with generateServerSideInterface
to true the plugin generates an interface named XXXSkeleton
that you can implement.
Then you have to configure maven build helper plugin, in order to include the generated sources.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${outputDirectory}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
my personal opinion is that axis is not the better chioce for java Web Service, JAX-WS compliant framework are the best choice, here are the how with jax-ws maven plugin, the generate sources are far better and clean then axis sources.
Upvotes: 0
Reputation: 12847
Axis2 is JAX-WS compliant, therefore you can use the wsimport
tool instead of wsdl2java
. I assume you've taken the contract first approach and you are generating the stubs from the WSDL file. Here is the doc to the wsimport maven plugin. A lot of things can be changed (destDir
for instance).
Maven clean deletes the generated source folder. I will have to protect the stub with the implemented business logic from deletion.
You can actually generate the stubs to your regular package structure (perhaps to its own package) and add include (or exclude) the generated files in the maven clean plugin configuration. If you use this mvn plugin, your IDE should add the generated files to the project classpath.
If I were you, I would definitely try to do as much as possible as JAX-WS compliant, because if you do so, you won't be vendor locked-in to Axis2. But you can switch to CXF, Metro or Jboss WS in the future. The services.xml
file is Axis2 specific.
So again some parts of the generated stubs should be protected from modification.
You can mark those resources as ignored by your SCM system. And mark them as derived in the Eclipse. Here is mvn plugin for it. If you do so, devs will be notified when trying to change them. There must be something similar in IntelliJ IDEA as well.
Upvotes: 1