http://www.perlmonks.org?node_id=943618

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

Hello, I'm trying to place the results of a SOAP::Lite SQL query into a variable and can't seem to find the right way to accomplish this. Here is the code I'm using to query the DB:
#!/usr/bin/perl use warnings; use SOAP::Lite + trace => 'all'; use Data::Dumper; use XML::Simple; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; my $DEBUG = 1; my $cucmip = '10.1.10.1'; my $axl_port = '8443'; my $axltoolkit = "AXLAPI.wsdl"; my $user = 'PerlAXL'; my $password = 'password'; my $error_text; Begin { sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ($user => $password) }; } my $cm = new SOAP::Lite encodingStyle=>'', uri => "$axltoolkit", proxy => "https://$cucmip:$axl_port/axl/" ; my $axl_sql = "select pkid from numplan where dnorpattern = \"5000\""; my $data = SOAP::Data->name("sql" => $axl_sql); my $res = $cm->executeSQLQuery($data); unless ($res->fault) { $Data::Dumper::Indent = 3; print Dumper($res->paramsall()); } else { print join ', ', $res->faultcode, $res->faultstring; }
From that query the reply is:
$VAR1 = { 'row' => { 'pkid' => 'db1835bc-9567-24e9-be1f-aaffc38c2490' } };
I'm after the pkid in the response but can't seem to get it by itself. I've been trying to use XML::Simple for this but can't get it to work. Any help in returning the pkid to a variable would be much appreciated. Thanks

Replies are listed 'Best First'.
Re: Parse Results of SOAP response
by Anonymous Monk on Dec 14, 2011 at 23:16 UTC
      Wow, it works like a charm. Thanks very much. Hoping to move past noob stage here sometime soon.....
        "We are all students in the Dojo".

        I have found that I never get out of the 'Noob' stage, I'm just a noob at something different. (Currently it's Moose and pack/unpack)

        ----
        I Go Back to Sleep, Now.

        OGB