The reason that the elements are not coming out in the order that you think you put them it, is that you are passing a hash reference as the second argument to SOAP::Data->name(), the elements in a hash are effectively in a random order which you cannot control. If you want more control over the structure of the generated XML you will need to explicitly create every element with SOAP::Data - you can find an example in Re: SOAP Beginner ... I hate to impose.

As to the question of why the elements need to be in a particular order, in general with XML this shouldn't matter but I have seen some XML parsers get upset about this when validating against a DTD, but you generally aren't doing this in a Web Service. If you (or the owner of the web service) care at all about interoperability, you will fix the server so that it behaves in an interoperable manner rather than hacking the client to work around it's quirks.

/J\


In reply to Re^3: Preserve the sequence of xml elements in the generated SOAP Envelope by gellyfish
in thread Preserve the sequence of xml elements in the generated SOAP Envelope by chanakya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.