CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl Soap Client

 



marloncos
Novice

Jul 26, 2013, 6:46 AM

Post #1 of 10 (807 views)
Perl Soap Client Can't Post

Hi all!
I'm new in perl world and facing some problems to do a perl soap script working fine.
I'm trying to connect my soap client to get some infos and in to every try, I got the error message:
[root@gateway1 marlon.ibr]# ./2_portaone_soap.pl
Logged in with session f0a34b1efc649e30265d8852284e1128
Pseudo-hashes are deprecated at ./2_portaone_soap.pl line 89.
Use of uninitialized value in concatenation (.) or string at ./2_portaone_soap.pl line 89.
Pseudo-hashes are deprecated at ./2_portaone_soap.pl line 89.
Use of uninitialized value in concatenation (.) or string at ./2_portaone_soap.pl line 89.
Pseudo-hashes are deprecated at ./2_portaone_soap.pl line 89.
Argument "\x{31}\x{43}..." isn't numeric in hash element at ./2_portaone_soap.pl line 89.
Pseudo-hashes are deprecated at ./2_portaone_soap.pl line 89.
Use of uninitialized value in concatenation (.) or string at ./2_portaone_soap.pl line 89.
Pseudo-hashes are deprecated at ./2_portaone_soap.pl line 89.
An error occured: Bad index while coercing array into hash at ./2_portaone_soap.pl line 89.

Can anyone help me to solve this errors?

Basically I would like to export the soap return to csv to upload it in a mysql database.

tks all!
marloncos
Attachments: portaone_soap.pl (3.79 KB)


FishMonger
Veteran / Moderator

Jul 26, 2013, 7:22 AM

Post #2 of 10 (805 views)
Re: [marloncos] Perl Soap Client [In reply to] Can't Post

Start by using Data::Dumper to dump out $CustomerXDRList prior to the concatenated print statement to see if it holds what you expect.


marloncos
Novice

Jul 26, 2013, 7:28 AM

Post #3 of 10 (801 views)
Re: [FishMonger] Perl Soap Client [In reply to] Can't Post

Hi FishMonger,

Thanks so much for your help!

I changed the code to print dumper $CustomerXDRList but the result is not a csv formart (columns, delimiters , etc), see below:

$VAR1 = [
bless( {
'subdivision' => '',
'CLD' => '551137912425',
'i_xdr' => '861726375',
'connect_time' => '2013-07-24T17:43:31',
'CLI' => '2416',
'charged_amount' => '0.07511',
'bit_flags' => '4',
'bill_time' => '2013-07-24T17:43:31',
'unix_connect_time' => '1374698611',
'country' => 'BRAZIL',
'bill_status' => 'O',
'description' => 'Brasil Fixo Area11 - NEXUS',
'account_id' => '2416',
'unix_disconnect_time' => '1374698633',
'charged_quantity' => '60',
'disconnect_cause' => '16',
'h323_conf_id' => '1CB05A7C F4A111E2 8B431803 73EE3A03',
'disconnect_time' => '2013-07-24T17:43:53'
}, 'XDRInfo' ),
bless( {
'subdivision' => '',
'CLD' => '551122511820',
'i_xdr' => '861721145',
'connect_time' => '2013-07-24T17:36:10',
'CLI' => '2416',
'charged_amount' => '0.18778',
'bit_flags' => '4',
'bill_time' => '2013-07-24T17:36:10',
'unix_connect_time' => '1374698170',
'country' => 'BRAZIL',
'bill_status' => 'O',
'description' => 'Brasil Fixo Area11 - TELESP',
'account_id' => '2416',
'unix_disconnect_time' => '1374698320',
'charged_quantity' => '150',
'disconnect_cause' => '16',
'h323_conf_id' => 'B709CD08 F49F11E2 8B431803 73EE3A03',
'disconnect_time' => '2013-07-24T17:38:40'
}, 'XDRInfo' ),
...

Could you please, help me?

Tks a lot.
marloncos


FishMonger
Veteran / Moderator

Jul 26, 2013, 7:55 AM

Post #4 of 10 (797 views)
Re: [marloncos] Perl Soap Client [In reply to] Can't Post

Why would you expect it to be csv format?

The output shows that $CustomerXDRList is not a simple hash ref. It's an array of blessed hash refs. You'll need to loop over that array.

This won't output in csv format, but see if it outputs the correct data.


Code
        foreach my $Customer ( @{ $CustomerXDRList } ) { 

print "XDR_ID: $Customer->{'i_xdr'}"
. "Account: $Customer->{'account_id'}"
. "H323_Conf_ID: $Customer->{'h323_conf_id'} "
. "CLI: $Customer->{'CLI'} "
. "CLD: $Customer->{'CLD'} "
. "Charged_Amount: $Customer->{'charged_amount'} "
. "Charged_Quantity: $Customer->{'charged_quantity'} "
. "Country: $Customer->{'country'} "
. "Subdivision: $Customer->{'subdivision'} "
. "Description: $Customer->{'description'} "
. "Disconnect_Cause_Code: $Customer->{'disconnect_cause'} "
. "Bill_Status: $Customer->{'bill_status'} "
. "Connect_Time: $Customer->{'connect_time'} "
. "Unix_Connect_Time: $Customer->{'unix_connect_time'} "
. "Disconnect_Time: $Customer->{'disconnect_time'} "
. "Unix_Disconnect_Time: $Customer->{'unix_disconnect_time'} "
. "Bill_Time: $Customer->{'bill_time'} "
. "Bit_Flags: $Customer->{'bit_flags'} "
. "\n";
}



(This post was edited by FishMonger on Jul 26, 2013, 8:00 AM)


marloncos
Novice

Jul 26, 2013, 8:07 AM

Post #5 of 10 (792 views)
Re: [FishMonger] Perl Soap Client [In reply to] Can't Post

Hi FishMonger,

I need it in to csv format to import this file before in a mysql database.

The output have correctly data and as you said, is not a csv format, all data are in one line, see:

Logged in with session e7a825b58bc8713b2944c82d2b76a583
XDR_ID: 861726375Account: 2416H323_Conf_ID: 1CB05A7C F4A111E2 8B431803 73EE3A03 CLI: 2416 CLD: 551137912425 Charged_Amount: 0.07511 Charged_Quantity: 60 Country: BRAZIL Subdivision: Description: Brasil Fixo Area11 - NEXUS Disconnect_Cause_Code: 16 Bill_Status: O Connect_Time: 2013-07-24T17:43:31...

It is possible to convert it in to a columns and field delimiter?

Tks,
marloncos


FishMonger
Veteran / Moderator

Jul 26, 2013, 8:40 AM

Post #6 of 10 (789 views)
Re: [marloncos] Perl Soap Client [In reply to] Can't Post


Quote
I need it in to csv format to import this file before in a mysql database.

Not true. You could insert the data directly into mysql without creating a csv file. But if you want to use the csv file, you can.


Quote
It is possible to convert it in to a columns and field delimiter?

Sure, no problem. I'd create an array of the hash keys in the order that you want them in the csv file.
e.g.,

Code
my @fields = qw(i_xdr account_id h323_conf_id CLI);


Then use that array in a hash slice which is then passed to the Text::CSV print function.

Code
# $csv is the Text::CSV object and $fh is the open filehandle to the csv file 
$csv->print($fh, [ @$Customer{@fields} ]);


I did not test that, so it may need a slight tweak, but is the shortest/cleanest approach I can think of.


marloncos
Novice

Jul 26, 2013, 9:37 AM

Post #7 of 10 (785 views)
Re: [FishMonger] Perl Soap Client [In reply to] Can't Post

Hi FishMonger,

I done your suggested and I can create a new csv file but the content of the file is only one line with all array content, see:


Code
        my $CustomerXDRList = $GetCustomerXDRListResponse->{'xdr_list'}; 

my @fields = qw(i_xdr account_id h323_conf_id CLI CLD charged_amount charged_quantity country subdivision description disconnect_cause bill_status connect_time unix_connect_time disconnect_time unix_disconnect_time bill_time bit_flags);

my $csv = Text::CSV->new ();
open my $fh, ">:encoding(utf8)", "test.csv" or die "test.csv: $!";
foreach my $XDR ( @{ $CustomerXDRList} ) {
$csv->print($fh, [ @$XDR{@fields} ]);}


Result:
861726375,2416,"1CB05A7C F4A111E2 8B431803 73EE3A03",2416,551137912425,0.07511,60,BRAZIL,,"Brasil Fixo Area11 - NEXUS",16,O,2013-07-24T17:43:31,1374698611,2013-07-24T17:43:53,1374698633,2013-07-24T17:43:31,4861721145,2416,"B709CD08 F49F11E2 8B431803 73EE3A03",2416,551122511820,0.18778,150,BRAZIL,,"Brasil Fixo Area11 - TELESP",...

thx,
marloncos


FishMonger
Veteran / Moderator

Jul 26, 2013, 9:45 AM

Post #8 of 10 (783 views)
Re: [marloncos] Perl Soap Client [In reply to] Can't Post

Try changing:

Code
my $csv = Text::CSV->new ();


To:

Code
my $csv = Text::CSV->new({ eol => "\n" });



(This post was edited by FishMonger on Jul 26, 2013, 9:52 AM)


marloncos
Novice

Jul 26, 2013, 9:53 AM

Post #9 of 10 (779 views)
Re: [FishMonger] Perl Soap Client [In reply to] Can't Post

Hi FishMonger,

Sorry, I can't see this option before.

One last question, and if you help me I would be glad. In a part of code, I set only one customer under i_customer option

Code
eval { 
my $GetCustomerXDRListRequest = {
i_customer => 97211,
from_date => "2013-07-24T00:00:00Z",
to_date => "2013-07-25T00:00:00Z"

};

But the system have a lot of customer and I need to do this manually many times.
Is there any one way to get this info of all customers without set "i_customer" manually?

thx,
marloncos


FishMonger
Veteran / Moderator

Jul 26, 2013, 9:59 AM

Post #10 of 10 (778 views)
Re: [marloncos] Perl Soap Client [In reply to] Can't Post

Sorry, I haven't done any SOAP scripts, so I can't answer that question.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives