java - 属性 "Any"已定义。使用 <jaxb :property> to resolve this conflict

标签 java xml web-services maven jaxb

我正在尝试使用 CXF 来使用 SOAP Web 服务。我遇到的问题是 JAXB 在尝试使用 WSDL 时抛出。它不喜欢的部分是:

<xs:sequence>
    <xs:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax"/>
    <xs:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax"/>
</xs:sequence>

它给出了错误:

Property "Any" is already defined. Use <jaxb:property> to resolve this conflict.

通过阅读其他问题,例如 this一,可以定义一个外部绑定(bind)文件来解决错误。问题是我不知道如何在 cxf-codegen-plugin 内执行此操作。谁能告诉我该怎么做?

这是我的 pom.xml 的相关部分

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.1.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/DataGeneratorInbox.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

最佳答案

The issue is I'm not sure how to do this within the cxf-codegen-plugin. Can anyone point me at how to do it?

您可以在cxf-codegen-plugin中添加绑定(bind)文件与 <bindingFiles> 属性,如下所示:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.1.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/DataGeneratorInbox.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
                <bindingFiles>
                    <bindingFile><!-- path to your file --></bindingFile>
                </bindingFiles>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

关于java - 属性 "Any"已定义。使用 <jaxb :property> to resolve this conflict,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33123195/

相关文章:

java - JList - 从点击中获取值(value)

java - 如何随时停止使用 SAX 解析 xml 文档?

python - 你如何用 python 解析嵌套的 XML 标签?

javascript - 将字符串变量附加到 Google Analytics 自定义事件的正确 JavaScript 语法

c# - WebService 不读取 web.config

java - 嵌套静态构建器类,对其管道的进一步解释

Java EE 安全性

java - 使用 OpenNTF Domino API 的 ViewEntryCollection - 比 getNthEntry(int i) 性能更高

ios - Alamofire API 请求在 swift 3 中因 responseSerializationFailed 而失败

oracle - 使用 PL/SQL 从 Apex Web 服务响应中获取响应头