Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimizing WSImport for Multiple WSDLs with Common Types

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?

like image 679
Hyangelo Avatar asked Aug 05 '11 15:08

Hyangelo


People also ask

How do I get the WSDL and schema from wsimport?

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.

What are the WSDL_Uri and wsimport parameters?

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.

What is wsimport command line tool?

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.

What are the optional parameters for wsimport?

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.


1 Answers

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.

like image 90
Robert Simmons Jr. Avatar answered Sep 28 '22 04:09

Robert Simmons Jr.