简体   繁体   中英

Why differences between XSD schema and WSDL schema?

I have WSDL where the schema part is:

<wsdl:types>
    <xs:schema>

        <!--  input schema -->
        <xs:element name="vs_ss_list" type="vsSsList" />
        <xs:element name="vs_ss" type="vsSs" />

        <xs:complexType name="vsSsList">
            <xs:sequence  maxOccurs="unbounded">
                <xs:element ref="vs_ss" />
            </xs:sequence>
        </xs:complexType>

        <xs:complexType name="vsSs">
            <xs:sequence>
                <xs:element name="vs" type="xs:string" />
                <xs:element name="ss" type="xs:string" />
            </xs:sequence>
        </xs:complexType>

        <!--  output schema -->
        .
        .
        .

    </xs:schema>
</wsdl:types>

If validating opposite XSd created from such schema, then this input is ok:

<vs_ss_list>

<vs_ss>
    <vs>123</vs>
    <ss>fgh</ss>
</vs_ss>
<vs_ss>
    <vs>456</vs>
    <ss>jkl</ss>
</vs_ss>

But if testing the running web service it needs this SOAP envelope to run:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <soapenv:Body>
    <vs_ss_list>
        <vs_ss>
            <vs_ss> 
                <vs>123</vs>
                <ss>fgh</ss>
            </vs_ss>
            <vs_ss> 
                <vs>123</vs>
                <ss>fgh</ss>
            </vs_ss>
        </vs_ss>
    </vs_ss_list>
 </soapenv:Body>
</soapenv:Envelope>

It needs for some unknown reason one more element than the validating to XSD.

Any idea why there are differences in between what is valid for XSD and what is valid for exactly the same schema in WSDL?

Your first input is missing a closing tag for <vs_ss_list> .

Assuming that's added at the end then the xml is still not valid because your XSD expects two elements.

    ...
    <xs:element name="vs_ss_list" type="vsSsList" />
    <xs:element name="vs_ss" type="vsSs" />
    ...

The first is your list and the second is a single vsSs .

Try removing the <xs:element name="vs_ss" type="vsSs" /> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM