daChf has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to write a script to access a web service. It returns XML in the form of a hash. I can't seem to access the data. The code I'm using looks like this:
use strict; use SOAP::Lite 'trace', 'debug'; use Mime::Base64 (); use XML::Simple; use Data::Dumper; my $loginToken = '209a2247-df9a-40f9-a7e1-6b755f184947'; my $messageID = '783679'; my $pageNumber = 1; my $server = SOAP::Lite ->uri('https://www.onecallnow.com/WebService/') ->on_action( sub { join '/', 'https://www.onecallnow.com/WebSe +rvice', $_[1] } ) #->proxy('http://localhost/WebService/OneCallNow.asmx?wsdl'); ->proxy('http://dev.onecallnow.com/WebService/OneCallNow.asmx? +wsdl'); my $returned = $server ->call(SOAP::Data->name('RetrieveMessageReportDetails')->attr({xml +ns => 'https://www.onecallnow.com/WebService/'}) => SOAP::Data->name('LoginToken')->value($loginToken)->type('s +:string'), SOAP::Data->name('MessageID')->value($messageID)->type('s:i +nt'), SOAP::Data->name('PageNumber')->value($pageNumber)->type('s +:int') ); my $xml = $returned->result;
(the loginToken and messageID will have expired by the time you read this) And the XML should look like this:
<Message MessageID="12345" PageNumber="1" PageCount="1" MinRecord="1" +MaxRecord="123"> <Deliveries> <Delivery Attempts="1" CallCreditsUsed="1.00"> <DeliveryStatus>Delivered to person</DeliveryStatus> <PhoneNumber>123-456-7890</PhoneNumber> <Name>John Smith</Name> <Delivered>02/06-2008 4:19 PM</Delivered> <TimeZone>CT</TimeZone> </Delivery> </Deliveries> </Message>
I've tried using a data dump, and the information is in there. Can anyone help me? Thanks in advance.

Replies are listed 'Best First'.
Re: SOAP::Lite HASH
by olus (Curate) on Mar 14, 2008 at 15:50 UTC

    $xml will be a reference to an hash, so you can use $xml->{'some_hash_key'} to access the values you're looking for.

      Thanks. That gets me the information in tags like PhoneNumber. However, I still don't understand how to get the values for CallCreditsUsed.