I am working on a fairly large WS project involving more than 20 different WebServices. These webservices, while independent from each other, share a sizable set of common types. We are using wsimport as an ant target in our build script to generate the proxy classes.
Problem: As the number of our WS(and corresponding WSDLs) has increased, we noticed that the build times for our proxy classes has been climbing up pretty steep. Upon further investigation(and profiling), we found out that a huge chunk of the build time was being spent by wsimport on repeatedly generating the common types. It has gotten to a point that generating, compiling and packaging these proxy classes and their common types are taking around 15-20 mins. This is a problem for us and we are looking for ways to trim down the build time.
Question: Is there a way to only generate the common types once? I've looked into some solutions found by googling. One involved writing a WSDL accumulator which parses the WSDLs and combines them into a single WSDL so wsimport is only called once. Another one hinted at using episode files but further investigation only yielded that there were problems with using that approach.
Note: I have seen some older similar questions but none of them had any answers.
wsimport multiple generated wsdl's
How can I tell wsimport that separate WSDL files are referring to the same object classes?
By using the -clientJar option for wsimport, the WSDL and schema are automatically downloaded and all the generated client-side artifacts are packaged into a JAR file.
The WSDL_URI is the only parameter that is required. The following parameters are optional for the wsimport command: Specifies the external JAX-WS or JAXB binding files. You can specify multiple JAX-WS and JAXB binding files by using the -b option; however, each file must be specified with its own -b option.
The wsimport command-line tool processes an existing Web Services Description Language (WSDL) file and generates the required artifacts for developing Java™ API for XML-Based Web Services (JAX-WS) web service applications. The generated artifacts are Java 5 compliant, making them portable across different Java versions and platforms.
The following parameters are optional for the wsimport command: Specifies the external JAX-WS or JAXB binding files. You can specify multiple JAX-WS and JAXB binding files by using the -b option; however, each file must be specified with its own -b option.
First of all I would use apache cxf to do that build as it can handle multiple WSDLs at the same time and is much more modern. It will be much more efficient and generate better classes. Second of all I would stop worrying about it unless the WSDL files are changing a lot. Instead i would put them into a separate artifact and build them once and then import them into the project as their own artifact. The only thing non-generated in that archive should be test code to test endpoints. As for the build, the Maven plugin config i have used with great success is pasted below.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${apache.cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/</sourceRoot>
<defaultOptions>
<catalog>${wsdlDir}/jax-ws-catalog.xml</catalog>
<bindingFiles>
<bindingFile>${wsdlDir}/jaxb-bindings.xml</bindingFile>
<bindingFile>${wsdlDir}/jaxws-bindings.xml</bindingFile>
</bindingFiles>
<noAddressBinding>true</noAddressBinding>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-xjc-Xbug671</extraarg>-->
<extraarg>-xjc-mark-generated</extraarg>
</extraargs>
</defaultOptions>
<wsdlOptions>
<wsdlOption>
<wsdl>${wsdlDir}/cis.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-bug671</artifactId>
<version>${apache.cxf.xjc.version}</version>
</dependency>
</dependencies>
</plugin>
This is set up to generate from only one WSDL but one could easily append more WSDLs and I have done so in other circumstances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With