进行唯一配置。
我正在创建一个使用几个web服务的Maven2客户端。我仅限于使用Axis2
或其他支持Apache HttpClient
的框架作为HTTP管道,因为这些服务需要与基于HttpClient
的托管证书解决方案集成。
我熟悉CXF的代码生成Maven插件,它允许在代码生成期间输入多个wsdl。但是,Axis2代码生成插件一次只能处理一个WSDL。
如何让Maven在代码生成阶段为每个WSDL运行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>
引用- Maven2 WSDL2Code插件指南wsdl2code命令行工具
你可以试试这个,我现在不能测试它,但我认为应该工作
<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>
我知道这是一个老问题,但有另一种方法来解决这个问题:
<build>
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.8.2</version>
<executions>
<execution>
<id>ws1</id>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<wsdlFile>src/main/resources/service1.wsdl</wsdlFile>
</configuration>
</execution>
<execution>
<id>ws2</id>
<goals>
<goal>wsdl2code</goal>
</goals>
<configuration>
<wsdlFile>src/main/resources/service2.wsdl</wsdlFile>
</configuration>
</execution>
</executions>
<configuration>
<unpackClasses>true</unpackClasses>
<databindingName>adb</databindingName>
<packageName>org.example.stackoverflow.axis2-maven</packageName>
<outputDirectory>target/generated-sources</outputDirectory>
<syncMode>sync</syncMode>
</configuration>
</plugin>
</plugins>
</build>
通过这种方式,您可以对所有wsdl