Skip to main content

Parsing a result object from SOAP::Lite

Parsing a result object from SOAP::Lite: "Parsing a result object from SOAP::Lite
Users frequently ask, 'how do you iterate over an array returned by a SOAP service that I call.' It asked frequently enough that I figure I should answer it here here. As always, it is a lot simpler than you might think, its just that SOAP::Lite's documentation leaves a lot to be desired.

SOAP::Lite returns a SOAP::SOM object for most SOAP calls. The SOM object provides a simple API for accessing any aspect of the response's SOAP envelope. One accesses those contents via simple XPATH statements.
For example, suppose for the following SOAP Envelope:

abcd wanted to access the value of the bar element. Then you would simply write your code as follows:

my $soap = SOAP::Lite
my $som = $soap->foo();
print $som->valueof('//fooResponse/bar');

Let's say that the SOAP Envelope returned contained an array. How would you iterate over each element of that array? Like so:

for my $t ($som->valueof('//catalog/product')) {
print $t->{title} . ' - ' . $t->{our_price} . '\n';

It is not always obvious, granted. But with a little tweaking here and there, and some familiarity with XPATH, you will quickly get the hang of it."
Post a Comment

Popular posts from this blog

Compact and Repair an Access Database. Add Ref. to : AdoDb, Jro

< ?xml version="1.0" encoding="utf-8" ?>

using ADODB;
using JRO;
using System.Configuration;
using System.Data.OleDb;
using System.IO;

public class CompactAndRepairAccessDb : System.Windows.Forms.Form
private System.ComponentModel.Container components = null;
private JRO.JetEngine jro;
private System.Windows.Forms.Button btnConfirm;
private System.Windows.Forms.TextBox tbxOriginalDbSize;
private System.Windows.Forms.TextBox tbxCompactedDbSize;
private OleDbConnection cnn;

public CompactAndRepairAccessDb() {

FileInfo fi = new FileInfo( ConfigurationSettings.AppSettings["PathOriginal"] );
int s = Convert.ToInt32( fi.Length/1000 );
this.tbxOriginalDbSize.Text = s.ToString() + " kb";

private void btnConfirm_Click(object sender, System.EventArgs e) {
// First close all instances of the database

VBScript to Automate login into gmail

Dim IE
Dim crtScreen
Set IE = CreateObject("InternetExplorer.Application")
USERNAME = "saudaziz"

With IE
.navigate ""
End With

'wait a while until IE as finished to load
Do while IE.busy
set WshShell = WScript.CreateObject("WScript.Shell")
Do While UCase(IE.Document.readyState) <> "COMPLETE"
WScript.Sleep 100
set WshShell=nothing
IE.document.all.Item("Email").value = USERNAME
IE.document.all.Item("pASSWD").value =pASSWORD
Set IE = Nothing