0

不要な xsi:type および xsi:schema タグを含む JAXWS 生成 XML の問題に直面しています。他のスレッドを読みましたが、これまでのところ役に立ちませんでした。私の場合、WSDL と XSD しかなく、jaxws-maven-plugin を使用して WSDL (XSD を含む) からコードを生成しています。

1) jaxws-maven-plugin 構成:

            <plugin>
               <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <bindingDirectory>${basedir}/src/main/wsdl</bindingDirectory>
                            <bindingFiles><bindingFile>Booking_normalized/Booking_1.0.1.0.xjb</bindingFile>
                </bindingFiles>
                            <wsdlDirectory>${basedir}/src/main/wsdl</wsdlDirectory>
                            <wsdlFiles>
                                <wsdlFile>Booking_normalized/Booking_1.0.1.0.wsdl</wsdlFile>
                            </wsdlFiles>
                            <target>2.1</target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

2) XSD (WSDL 内にインポート):

    <xs:complexType name="ScheduleQueryType">
        <xs:annotation>
            <xs:documentation>Describes a Schedule</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="start" type="ScheduleQueryTypestart"/>
            <xs:element name="end" type="ScheduleQueryTypeend"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="ScheduleQueryTypestart">
        <xs:annotation>
            <xs:documentation xml:lang="en">
                    The start element contains the origin locationCode and departure dateTime
                </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="DateTimeLocationType">
                <xs:attribute name="windowBefore" type="xs:duration" use="optional">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">A period of time that can be applied to another time resulting in an earlier range of time.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="windowAfter" type="xs:duration" use="optional">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">A period of time that can be applied to another time resulting in a later range of time.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="ScheduleQueryTypeend">
        <xs:annotation>
            <xs:documentation xml:lang="en">
                    The end element contains the destination locationCode and arrival dateTime.
                </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="DateTimeLocationType">
                <xs:attribute name="windowBefore" type="xs:duration" use="optional">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">A period of time that can be applied to another time resulting in an earlier range of time.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="windowAfter" type="xs:duration" use="optional">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">A period of time that can be applied to another time resulting in a later range of time.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="DateTimeLocationType">
        <xs:annotation>
            <xs:documentation xml:lang="en">Describes DateTime and Location</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="locationCode" minOccurs="0">
                <xs:annotation>
                    <xs:documentation xml:lang="en">Code used to identify a location</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                    <xs:simpleContent>
                        <xs:extension base="ota:StringLength1to16">
                            <xs:attribute name="type" type="ota:AlphaNumericStringLength1to8" use="optional">
                                <xs:annotation>
                                    <xs:documentation>Type of location code</xs:documentation>
                                </xs:annotation>
                            </xs:attribute>
                        </xs:extension>
                    </xs:simpleContent>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="dateTime" type="ota:DateOrDateTimeType">
            <xs:annotation>
                <xs:documentation>Date and optional time</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="locationName" type="ota:StringLength1to64" use="optional">
            <xs:annotation>
                <xs:documentation xml:lang="en">Name of the location</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

3) 生成された XML:

<ns5:Schedule>
            <ns5:Segment TID="SEG_1" Inventory="FRR">
                <ns2:start xsi:type="ns2:ScheduleQueryTypestart" dateTime="2015-05-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <ns2:locationCode type="NLS">FRPLY</ns2:locationCode>
                </ns2:start>
                <ns2:end xsi:type="ns2:ScheduleQueryTypeend" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <ns2:locationCode type="NLS">FRLPD</ns2:locationCode>
                </ns2:end>
                <ns2:serviceProvider Code="SNF"/>
                <ns2:identifier>6609</ns2:identifier>
            </ns5:Segment>
        </ns5:Schedule>

上記の生成された XML でわかるように、開始タグと終了タグには xmlns:xsi および xsi:type タグが含まれています。私はそれらを取り除きたいです。助言がありますか?

生成された XML の他の項目は問題ないことに注意してください (xsi プレフィックスが含まれていません)。

ここでは、これは単純な型変換ではありません (これは javaType バインディングを使用して解決されるはずです。複雑な型を使用することの方が多いです。プラグインの問題でしょうか、それとも XSD に何か問題があるのでしょうか?

ありがとう。

4

1 に答える 1

0

どうやら、開始タイプと終了タイプは複数のタイプで使用されていました。ここで XSD 全体について言及できなかったことを残念に思います。[使用しているビルダーには問題がほとんどないことにも注意しました]。そのため、JAXB は type 属性を付けて区別する必要がありました。

問題が見つかり、解決しました。

ありがとうございます。

于 2015-05-06T11:59:29.973 に答える