I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-06-01 23:24:04.752657-07 by lom42
wsdl2perl and arrays

Hello,


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. This is where I would expect to access all returned lines.


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.


The returned xml looks fine to me:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/en +velope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/X +MLSchema"> <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.

Direct Responses: 12741 | 12743 | Write a response