Hello monks,

I am using generated classes from wsdl2perl, which after the soap call should return (between other things) an array of objects. My issue is that whatever I do I cannot access more than one element in this array, whereas I can see that the xml, both generated and received, are correct.

The wsdl is at https://www.wdl.com/api/ordering.asmx?WSDL and my issue is with the ArrayOfOrderPlacedLine element. I would like to access all the OrderPlacedLine inside.

All classes have been generated in the WDL tree.

The code is:

my $interface = WDL::Interfaces::ordering::orderingSoap->new(); my $confirmation = $interface->PlaceOrder({ request => { IsTest => 1, Email => 'tartiflette@cheese.com', Password => 'tartiflette', PurchaseOrderRef => 'ref_42', Lines => [{CatalogueNo => 42, Qty => 5}, {CatalogueNo => 43, Qty => 6}] } }); # $results isa(WDL::Types::OrderConfirmation) my $results = $confirmation->get_PlaceOrderResult(); # $placedLines isa(WDL::Types::ArrayOfOrderPlacedLine) my $placedLines = $results->get_PlacedLines();
From there, ref($placedLines ) eq WDL::Types::ArrayOfOrderPlacedLine, scalar(@$placedLines) == 1, $placedLines->[0] references the same object as $placedLines, $placedLines-> 1 is undef.

The only method I can call on this object (according to doc and generated source) are {get|set}_OrderPlacedLine. This is not an iterator, I checked this, and $placedLines->get_OrderPlacedLine->get_Qty() gives me the expected result for the 1st line only. This is where I would expect to access all returned lines.

The returned xml looks fine to me:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http: +//schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/20 +01/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <PlaceOrderResponse xmlns="http://tempuri.org/"> <PlaceOrderResult> <PlacedLines> <OrderPlacedLine> <CatalogueNo>42</CatalogueNo> <Qty>5</Qty> <ItemPrice>2.62</ItemPrice> </OrderPlacedLine> <OrderPlacedLine> <CatalogueNo>43</CatalogueNo> <Qty>6</Qty> <ItemPrice>2.58</ItemPrice> </OrderPlacedLine> </PlacedLines> <RejectedLines/> <PurchaseOrderRef>ref_42</PurchaseOrderRef> <OrderRef>TESTNOTCREATED</OrderRef> </PlaceOrderResult> </PlaceOrderResponse> </soap:Body> </soap:Envelope>

Would any of you know what I have done wrong here, and how I can access all the lines of the returning xml? Any help would be greatly appreciated.


In reply to SOAP::WSDL, wsdl2perl and arrays by lom

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.