Java – wsimport that optimizes multiple WSDL using common types

I'm working on a fairly large WS project involving more than 20 different web services Although these web services are independent of each other, they share a large number of common types We use wsimport as the ant target in the build script to generate the proxy class

Problem: as the number of our WS (and corresponding WSDL) increases, we notice that the construction time of proxy classes has been rising After further investigation (and analysis), we found that wsimport is spending a lot of time repeatedly generating common types Already, it takes about 15-20 minutes to generate, compile and package these proxy classes and their common types This is a problem for us, and we are looking for ways to reduce construction time

Question: is there any way to generate common types only once? I have studied some solutions found by Google search One involves writing a WSDL accumulator that parses WSDL and combines them into a WSDL, so wsimport is called only once Another suggested the use of plot files, but further investigation only found that there were problems with this method

Note: I see some older similar questions, but none of them have any answers

wsimport multiple generated wsdl’s

How can I tell wsimport that separate WSDL files are referring to the same object classes?

Solution

First, I'll use Apache CXF for this build because it can handle multiple WSDL at the same time and is more modern It will be more efficient and produce better courses Second, unless the WSDL file changes a lot, I won't worry anymore Instead, I put them in a separate artifact, build them once, and then import them into the project as my own artifact The only thing not generated in the archive should be the test endpoint test code For the build, I have used the successful Maven plug-in configuration 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 to generate from only one WSDL, but it is easy to attach more WSDL, which I have done in other cases

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>