CXF:wsdl2java 错误 - WSDL 包含重复名称

CXF: wsdl2java errors - WSDL contains duplicate names

我正在尝试使用来自第 3 方的 SOAP Web 服务。我有一个 Maven 项目,我正在尝试使用 cxf-codegen-plugin 运行 在提供的 WSDL 上使用 wsdl2java 生成代码。

WSDL 的问题是在同一复杂类型中存在同名的元素和属性。因此,我在尝试 运行 mvn clean install:

时收到以下错误
Property "SomeId" is already defined. Use <jaxb:property> to resolve this conflict.

环顾四周解决此问题的方法似乎是添加绑定文件以重命名出现错误的 属性 名称。

我的绑定文件如下所示:

<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

    <jxb:bindings node=".//s:attribute[@name='SomeId']">
        <jxb:property name="anotherId" />
    </jxb:bindings>
</jxb:bindings>

WSDL 片段:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
  xmlns:tns=“namespace” xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  targetNamespace=“namespace”>
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace=“namespace”>
      <s:element name="GetData">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="request">
              <s:complexType>
                <s:sequence>
                  <s:element minOccurs="0" maxOccurs="1" name="Nbr" type="s:string" />
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="GetDataResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="GetDataResult">
              <s:complexType>
                <s:sequence>
                  <s:element minOccurs="0" maxOccurs="1" name="ITEM">
                    <s:complexType>
                      <s:sequence>
                        <s:element minOccurs="0" maxOccurs="1" name="Pty">
                          <s:complexType>
                            <s:sequence>
                           <s:element minOccurs="0" maxOccurs="1" name=“SomeId” type="s:string"/> 
                            </s:sequence>
                            <s:attribute name="SomeId" type="s:string" />
                          </s:complexType>

(注:'namespace'隐藏了公司名称。)

并且我已将我的 POM 指向绑定文件:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>${basedir}/src/main/resources/META-INF/wsdl/a.wsdl</wsdl>
            <wsdlLocation>classpath:META-INF/wsdl/a.wsdl</wsdlLocation>
            <packagenames>
              REMOVED
            </packagenames>
            <extraargs>
              <extraarg>-fe</extraarg>
              <extraarg>jaxws21</extraarg>
              <extraarg>-autoNameResolution</extraarg>
              <extraarg>-exsh</extraarg>
              <extraarg>true</extraarg>
            </extraargs>
            <bindingFiles>
              <bindingFile>${basedir}/src/main/resources/META-INF/wsdl/binding.xsd</bindingFile>
            </bindingFiles>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>

问题:

当我使用此设置 运行 'mvn clean install' 时,出现以下错误:

XPath evaluation of ".//s:attribute[@name='SomeId']" results in empty target node

我已经将节点路径更改为指向元素,并且还使用了完整的节点路径结构,例如node="wsdl:definitions/wsdl:types...." 但我一直收到同样的错误。感觉我在这儿兜圈子

如果有人能看到我出错的地方并指出给我,我将不胜感激,因为这是我第一次尝试实现这样的东西。

提前致谢。

所以我最终弄明白了。结果是 jaxb:bindings 无法解析节点路径。所以我使用 jaxws 来解析路径和 jaxb 来更新 属性 名称。

工作绑定文件如下所示:

<jaxws:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:s="http://www.w3.org/2001/XMLSchema" version="2.1">
  <jaxws:bindings node=".//s:element[@name='SomeId']">
    <jaxb:property name="anotherId" />
  </jaxws:bindings>
</jaxws:bindings>