enter image description here

在我的maven项目中,为了使用apache cxf生成客户端存根,我已经按如下方式配置了pom:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
      <execution>
        <id>generate-sources</id>
        <phase>generate-sources</phase>
        <goals>
          <goal>wsdl2java</goal>
        </goals>
        <configuration>
          <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
            <frontEnd>jaxws21</frontEnd>
            <markGenerated>true</markGenerated>
            <xjcargs>
              <xjcarg>-Xts</xjcarg>
            </xjcargs>
          </defaultOptions>
          <wsdlOptions>
            <wsdlOption>
              <wsdl>${basedir}/src/main/resources/wsdl/MyServiceA_v1.wsdl</wsdl>
              <wsdlLocation>classpath:wsdl/MyServiceA_v1.wsdl</wsdlLocation>
            </wsdlOption>
            <wsdlOption>
              <wsdl>${basedir}/src/main/resources/wsdl/MyServiceB_v1.wsdl</wsdl>
              <wsdlLocation>classpath:wsdl/MyServiceB_v1.wsdl</wsdlLocation>
            </wsdlOption>
     </wsdlOptions>
        </configuration>
      </execution>
    </executions>
    <dependencies>
      <dependency>
        <groupId>org.apache.cxf.xjcplugins</groupId>
        <artifactId>cxf-xjc-ts</artifactId>
        <version>2.6.1</version>
      </dependency>
    </dependencies>
  </plugin>
</plugins>

然后我从服务器下载了"manually"所有WSDL,它将Web服务公开到我的资源项目文件夹“ \my-project\src\main\resources\wsdl " and all the related XSDs inside my xsd project folder " \my-project\src\main\resources\wsdl\xsd ” . 之后我手动更改了WSDLs文件中的所有schemaLocation,以便只有相对路径(然后运行cxf生成,正确生成了java客户端存根) .

Example:

在wsdl里面我改变了:

<xs:import namespace="http://ws.myproject.priv.schema/MyServiceA/v1" schemaLocation="http://161.29.123.124:8080/web-1.0/ws/MyServiceA_v1?myServiceA_v1.0.xsd"/>

与相对路径(与文件夹\ my-project \ src \ main \ resources \ wsdl \ xsd相关)

<xs:import namespace="http://ws.myproject.priv.schema/MyServiceA/v1" schemaLocation="xsd/myServiceA_v1.0.xsd"/>

有没有办法(使用maven,apache cxf,ant或其他...)自动将所有WSDL和XSD从服务器下载到我的文件夹,然后使用我的项目相对路径自动更改服务器路径?如何自动完成此过程?