将多个 WSDL 与 Axis2 wsdl2code Maven 插件配合使用

2022-09-03 06:02:27

我正在使用 Maven2 创建一个使用多个 Web 服务的客户端。我仅限于使用或其他支持Apache的框架作为HTTP管道,因为这些服务需要与基于的托管证书解决方案集成。Axis2HttpClientHttpClient

我熟悉CXF的代码生成Maven插件,它允许在代码生成期间输入多个WSDL。但是,Axis2 代码生成插件一次只能处理一个 WSDL。

如何在代码生成阶段为每个 WSDL 运行 Maven?为此,我是否需要多个配置文件?wsdl2code

POM 的构建部分如下所示:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <unpackClasses>true</unpackClasses>
                <databindingName>adb</databindingName>
                <packageName>org.example.stackoverflow.axis2-maven</packageName>
                <!-- only one of these actually gets used by code generator -->
                <wsdlFile>src/main/resources/service1.wsdl</wsdlFile>
                <wsdlFile>src/main/resources/service2.wsdl</wsdlFile>
                <outputDirectory>target/generated-sources</outputDirectory>
                <syncMode>sync</syncMode>
            </configuration>
        </plugin>
    </plugins>
</build>

引用


答案 1

你可以试试这个,我现在不能测试它,但我认为应该工作

   <plugin>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
            <execution>
                <id>ws1</id>
                <goals>
                    <goal>wsdl2code</goal>
                </goals>
                <configuration>
                   <unpackClasses>true</unpackClasses>
                   <databindingName>adb</databindingName>
                   <packageName>org.example.stackoverflow.axis2-maven</packageName>
                   <wsdlFile>src/main/resources/service1.wsdl</wsdlFile>
                   <outputDirectory>target/generated-sources</outputDirectory>
                   <syncMode>sync</syncMode>
                </configuration>
            </execution>
            <execution>
                <id>ws2</id>
                <goals>
                    <goal>wsdl2code</goal>
                </goals>
                <configuration>
                   <unpackClasses>true</unpackClasses>
                   <databindingName>adb</databindingName>
                   <packageName>org.example.stackoverflow.axis2-maven</packageName>
                   <wsdlFile>src/main/resources/service2.wsdl</wsdlFile>
                   <outputDirectory>target/generated-sources</outputDirectory>
                   <syncMode>sync</syncMode>
                </configuration>
            </execution>
        </executions>
    </plugin>

答案 2

推荐