【问题标题】:CXF wsdl2java not reading schema properlyCXF wsdl2java 没有正确读取模式
【发布时间】:2014-10-08 20:16:50
【问题描述】:

我正在使用配置为使用 WSDL 生成 java 类的以下 wsdl2java 插件。

<plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${basedir}/src/main/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>src/main/resources/XXXXService.wsdl</wsdl>
                                <validate>none</validate>
                                <extraargs>
                                    <extraarg>-server</extraarg>
                                    <extraarg>-impl</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>http://XXX/YY=XXX</extraarg>
                                    <extraarg>-autoNameResolution</extraarg>
                                </extraargs>

                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

现在,我的 WSDL 中包含以下架构。

<xsd:include schemaLocation="myschema.xsd" xmlns="tns"></xsd:include>

当我的元素定义在我的 WSDL 中时,如下所示,它会为 myElement 生成一个类,这很好:

<xsd:element name="myElement">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"
                    minOccurs="1">
                </xsd:element>
                <xsd:element name="b" type="xsd:string"
                    minOccurs="1">
                </xsd:element>                  
            </xsd:sequence>
        </xsd:complexType>

但是当我在 WSDL 中的元素定义引用了架构中的 ComplexType 定义时。那么元素类 aaa 不会生成,而只会生成 aaaType 类。

<xsd:element name="aaa"
        type="tns:aaaType">
</xsd:element>

有没有一种方法可以指定 wsdl2java 来生成两个类 aaaaaaType 并在 aaa 中引用 aaaType > ?

【问题讨论】:

    标签: xsd cxf wsdl2java cxf-codegen-plugin


    【解决方案1】:

    您可以在 WSDL 和架构上检查 xmlns:tnstargetNamespace

    &lt;xsd:element name="aaa"... - 它可以在模式本身中定义。

    您可以尝试浏览 WSDL 并检查它是否正确,因为问题似乎与架构包含有关。

    【讨论】:

      猜你喜欢
      • 2021-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-07
      • 1970-01-01
      • 2018-03-22
      相关资源
      最近更新 更多