ixM
ixM

Reputation: 1264

Order of unbounded elements in xmlschema sequence

I'm currently developing an application that uses webservices (SOAP 1.2). I'm interested in knowing if I can rely on the order of unbounded elements in a xmlschema sequence. Here is my definition of that sequence in the wsdl I'm using.

<xsd:complexType name="IdList">
  <xsd:sequence>
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="id" type="xsd:integer"/>
  </xsd:sequence>
</xsd:complexType>

Does that give me any kind of guarantee on the order of the elements? Say this is an excerpt of the associated soap message:

<web:globalRecipientIds>
  <!--Zero or more repetitions:-->
  <web:id>1</web:id>
  <web:id>15</web:id>
  <web:id>7</web:id>
</web:globalRecipientIds>

Does that mean that the receiving end will treat it in the order that it appears in the SOAP message? Is this something that depends on the implementation of the receiving end? If it does, I generated the receiving end using wsdl2java from apache axis to generate the java code from the wsdl file. Can you tell me something specific about this?

Upvotes: 2

Views: 1454

Answers (1)

MiMo
MiMo

Reputation: 11973

The order of XML elements is significative - regardless of the schema - e.g.

<web:globalRecipientIds>
  <web:id>1</web:id>
  <web:id>15</web:id>
  <web:id>7</web:id>
</web:globalRecipientIds>

and

<web:globalRecipientIds>
  <web:id>15</web:id>
  <web:id>1</web:id>
  <web:id>7</web:id>
</web:globalRecipientIds>

are two different XML, and XML tools (should) preserve and recognize the order of elements.

Having said that, this does not guarantee that 'the receiving end will treat it in the order that it appears in the SOAP message' - depends on what the receiving end does with the XML. It receives an ordered list of ids, but if (for example) puts those ids in a dictionary or some other hashed structure the order is lost.

Upvotes: 2

Related Questions