使用CXF从Maven生成WSDL2Java

时间:2013-03-08 12:17:17

标签: java maven wsdl cxf wsdl2java

例如我有这样的cxf-codegen-plugin:

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-rt-bindings-soap</artifactId>
                    <version>${cxf.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>generate-jaxb</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <additionalJvmArgs>-Dfile.encoding=UTF8</additionalJvmArgs>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>src/main/resources/wsdl/MyWsdl.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-wsdlLocation</extraarg>
                                    <extraarg></extraarg>
                                    <extraarg>-client</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

当我的WSDl存储在我的本地项目中时,它正常工作:

src/main/resources/wsdl/MyWsdl.wsdl

我想要实现的是从远程Maven存储库下载WSDL并以某种方式将其传递给<wsdl>元素。

类似的东西:

<wsdl>
 <dependency>...</dependency>
</wsdl>

我找不到有关如何执行此操作的任何信息。这样的选项是否存在?或者它应该以某种方式完成,然后尝试在<wsdl>元素中传递WSDL?

请建议。

1 个答案:

答案 0 :(得分:3)

您可以使用<wsdlArtifact>从maven加载WSDL:

<configuration>
    ...
    <wsdlOptions>
        <wsdlOption>
            <wsdlArtifact>
                <groupId>your.group.id</groupId>
                <artifactId>YourWSDLService</artifactId>
                <version>0.1.2-SNAPSHOT</version>
            </wsdlArtifact>
        </wsdlOption>
    </wsdlOptions>
    ...
</configuration>