CXF wsdl2java设置多个wsdl的wsdlLocation

时间:2017-11-06 09:46:36

标签: wsdl cxf wsdl2java

我尝试通过多个wsdl文件的CXF wsdl2java生成类。但我无法将这些wsdl文件的wsdl位置设置为项目的相对路径。我已经看到了每个wsdl的解决方案设置选项,如下所示:

<configuration> 
            <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
            <wsdlOptions>
                <wsdlOption>
                    <wsdl>${project.basedir}/src/main/resources/wsdl/FooService.wsdl</wsdl>
                    <wsdlLocation>classpath:wsdl/FooService.wsdl</wsdlLocation>
                </wsdlOption>
            </wsdlOptions>
        </configuration>

但我不想对每个案例都这样做。我的代码中有这个:

<configuration>
                        <sourceRoot>${generated.dir}</sourceRoot>
                        <defaultOptions>
                            <noAddressBinding>true</noAddressBinding>
                            <bindingFiles>
                                <bindingFile>${basedir}/src/main/resources/META-INF/cxf/date-binding.xml
                                </bindingFile>
                            </bindingFiles>
                        </defaultOptions>
                        <wsdlOption>
                            <extraargs>
                                <extraarg>-fe</extraarg>
                                <extraarg>jaxws21</extraarg>
                            </extraargs>
                        </wsdlOption>
                        <wsdlRoot>${basedir}/src/main/resources/META-INF/cxf/wsdl</wsdlRoot>
                        <includes>
                            <include>*.wsdl</include>
                        </includes>
                    </configuration>

如何在不设置每个wsdl的情况下设置wsdlLocation?

1 个答案:

答案 0 :(得分:0)

我明白了。

您必须在配置中添加wsdlRoot部分。此外,您必须添加包含通配符的include部分。

这是我的插件部分

        <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>
                    <configuration>
                        <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                        <wsdlRoot>${basedir}/src/main/resources/wsdl/</wsdlRoot>
                        <includes>
                            <include>**/*.wsdl</include>
                        </includes>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>