By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,253 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,253 IT Pros & Developers. It's quick & easy.

SOAP::Lite XML hash

P: 8
I'm attempting to write an application using SOAP::Lite that receives XML code from a WebService. The XML code should look like the following:

Expand|Select|Wrap|Line Numbers
  1. <Message MessageID="12345" PageNumber="1" PageCount="1" MinRecord="1" MaxRecord="123">
  2.   <Deliveries>
  3.     <Delivery Attempts="1" CallCreditsUsed="1.00">
  4.       <DeliveryStatus>Delivered to person</DeliveryStatus>
  5.       <PhoneNumber>123-456-7890</PhoneNumber>
  6.       <Name>John Smith</Name>
  7.       <Delivered>02/06-2008 4:19 PM</Delivered>
  8.       <TimeZone>CT</TimeZone>
  9.     </Delivery>
  10.   </Deliveries>
  11. </Message>
  12.  
What I'm getting is something similar to HASH(0x31a2484). How can I access this data or even convert this into a string?

Thanks in advance.
Mar 10 '08 #1
Share this Question
Share on Google+
4 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
I'm attempting to write an application using SOAP::Lite that receives XML code from a WebService. The XML code should look like the following:

Expand|Select|Wrap|Line Numbers
  1. <Message MessageID="12345" PageNumber="1" PageCount="1" MinRecord="1" MaxRecord="123">
  2.   <Deliveries>
  3.     <Delivery Attempts="1" CallCreditsUsed="1.00">
  4.       <DeliveryStatus>Delivered to person</DeliveryStatus>
  5.       <PhoneNumber>123-456-7890</PhoneNumber>
  6.       <Name>John Smith</Name>
  7.       <Delivered>02/06-2008 4:19 PM</Delivered>
  8.       <TimeZone>CT</TimeZone>
  9.     </Delivery>
  10.   </Deliveries>
  11. </Message>
  12.  
What I'm getting is something similar to HASH(0x31a2484). How can I access this data or even convert this into a string?

Thanks in advance.
Well, for us to better help you, we are going to have to see your code. Can you please share it here and someone will hopefully have some fairly useful input for you.

Regards,

Jeff
Mar 10 '08 #2

P: 8
Expand|Select|Wrap|Line Numbers
  1. my $returned = $server
  2.   ->call(SOAP::Data->name('RetrieveMessageReportDetails')->attr({xmlns => 'https://www.onecallnow.com/WebService/'}) =>
  3.    SOAP::Data->name('LoginToken')->value($loginToken)->type('s:string'),
  4.    SOAP::Data->name('MessageID')->value($messageID)->type('s:int'),
  5.    SOAP::Data->name('PageNumber')->value($pageNumber)->type('s:int')
  6.   );
  7.  
  8. my $xml = $returned->result;
  9.  
  10. print "$xml\n";
  11.  
This displays the HASH.
Mar 10 '08 #3

P: 3
Expand|Select|Wrap|Line Numbers
  1. my $returned = $server
  2.   ->call(SOAP::Data->name('RetrieveMessageReportDetails')->attr({xmlns => 'https://www.onecallnow.com/WebService/'}) =>
  3.    SOAP::Data->name('LoginToken')->value($loginToken)->type('s:string'),
  4.    SOAP::Data->name('MessageID')->value($messageID)->type('s:int'),
  5.    SOAP::Data->name('PageNumber')->value($pageNumber)->type('s:int')
  6.   );
  7.  
  8. my $xml = $returned->result;
  9.  
  10. print "$xml\n";
  11.  
This displays the HASH.
You could use something like the following code to get at the data:

Expand|Select|Wrap|Line Numbers
  1. ...
  2. @items = $xml->valueof('//Message/Deliveries/Delivery');
  3.  
  4. foreach my $item (@items) {
  5.   print "Delivery to: $item->{'DeliveryName']";
  6.   print "Delivery Status is: $item->{'DeliveryStatus']";
  7. };
  8. ...
  9.  
I might be a little off in the 'valueof' statement, based on your XML. But, it worked for me using SOAP::LIte. If you would like to exchange some scripts, let me know. I've got a few that use SOAP::Lite with Perl. I can also give you the result XML, so you know what the script is getting at.

Good luck!

Mark
Mar 11 '08 #4

P: 8
Thanks for the reply.

However, when I tried it it said that it couldn't call method "valueof" on an unblessed reference. Does this mean that I have to create some sort of object class?
Mar 12 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.