Search code examples
xmlwsdlxsd

Difference between a named Complex Type and an anonymous Complex Type in an Element


What is the difference between...

<xsd:element name=”add”>
<xsd:complexType>
    <xsd:sequence>
        <xsd:element name="x" type="xsd:float"/>
        <xsd:element name="y" type="xsd:float"/>
    </xsd:sequence>
</xsd:complexType>
</xsd:element>

and...

<xsd:complexType name=”add”>
    <xsd:sequence>
        <xsd:element name="x" type="xsd:float"/>
        <xsd:element name="y" type="xsd:float"/>
    </xsd:sequence>
</xsd:complexType>

Both would appear as:

<add>
    <x type="xsd:float">1.00</x>
    <y type="xsd:float">2.00</x>
</add>

In the SOAP envelope...so is there any definitive difference between the two definitions?


Solution

  • Hi you should use element type if this document appear as root element in your SOAP envelope, and complexType type can't appear as root element they normally appear in child elements/not in root element.