oldwarrior32 has asked for the wisdom of the Perl Monks concerning the following question:
Hi. I would like to ask for your wisdom. I hope if you can guide me. If not, it's OK :)(is an oscure topic presented by a noob and with not low level details).
I need to connect to some machines using SOAP protocol, the idea is to connect to one machine, get the data, connect to the next machine, get the data and so on. I am using a foreach loop when in each loop i change the IP address.
I can connect to one machine at once and get the data, but using the loop in the second iteration I got an error.
use warnings; use SOAP::Lite + trace => 'debug'; use Data::Dumper; use MIME::Base64; my $cucmip = "10.10.100.1"; my $axl_port = "8443"; my $user = "ccm"; my $password = "password"; my $axltoolkit = "AXLAPI.wsdl"; my $cm; my $res; $cm = SOAP::Lite ->encodingStyle('') ->uri($axltoolkit) ->proxy("https://$cucmip:$axl_port/axl/", timeout => 5); $cm->transport->http_request->header ( 'Authorization' => 'Basic ' . encode_base64("$user:$password", '')); #axl request my $test = new SOAP::Data(); $res = $cm->listPhoneByName($test->name("searchString" => "%")); unless ($res->fault) { print $res->valueof('//listPhoneByNameResponse/return/phone'); } else { print join ', ', "FAULTCODE: " . $res->faultcode, "FAULTSTRING: " . $res->faultstring; }
That code works just fine. But when I add a loop to iterate a pool of IP addresses i got the error.
use warnings; use SOAP::Lite + trace => 'debug'; use Data::Dumper; use MIME::Base64; my $cucmip = "10.10.100.1"; my $axl_port = "8443"; my $user = "ccm"; my $password = "password"; my $axltoolkit = "AXLAPI.wsdl"; my $cm; @ips = qw(10.10.100.1 10.10.100.2 10.10.100.3); my $res; foreach(@ips){ $cm = SOAP::Lite ->encodingStyle('') ->uri($axltoolkit) ->proxy("https://$_:$axl_port/axl/", timeout => 5); $cm->transport->http_request->header ( 'Authorization' => 'Basic ' . encode_base64("$user:$password", '')); #axl request my $test = new SOAP::Data(); $res = $cm->listPhoneByName($test->name("searchString" => "%")); unless ($res->fault) { print $res->valueof('//listPhoneByNameResponse/return/phone'); } else { print join ', ', "FAULTCODE: " . $res->faultcode, "FAULTSTRING: " . $res->faultstring; } }
The error is this:
SOAP::Transport::HTTP::Client::send_receive: 500 Status read failed: invalid argument
Status read failed: Invalid argument at C:/strawberry /perl/site/lib/Net/HTTP/Methods.pm line 269. 500 Status read failed: Invalid argument. at cm.pl lin e 41
Line 41 is:
$res = $cm->listPhoneByName($test->name("searchString" => "%"));I think is some low level thing, since if I run the same program, once a time, but with a different IP address I got the data from the 3 machines.
In other words, the program is this: start a TCP session using SOAP destined to IP address 10.10.100.1. Get the requested data. Close the session(this works fine). Start a new TCP session using SOAP to IP address 10.10.100.2. Get the data(here the program crashes).
As a last resort I copied the first code two times in the same file. Changed variable names in the copied code so all objects are new. In this way I got the same program two times in the same file simulating a loop with two iterations, but with different variable names. The error appears again.
The only solution I got is to run the program once a time with a different IP address each time. In this way I got the data required but involves some extra hand work :(.
By the way, I tried the sleep command to delay the execution of each interation by 5 or 10 seconds(thinking about a buffer thing) with no success.
I made a packet capture too. Unfortunately the traffic is encripted so I can't find a clue about problem reading the payload of the http traffic. But my computer resets the session, not the remote machine.
A last note. The Soap module has a debug option. This prints the message sended to the remote machine. In each iteration is exactly the same, except for the IP address.
Any suggestion is welcome!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with SOAP::Lite module
by Anonymous Monk on Jun 07, 2012 at 06:53 UTC | |
by runrig (Abbot) on Jun 07, 2012 at 16:59 UTC | |
by Anonymous Monk on Jun 07, 2012 at 22:28 UTC | |
by runrig (Abbot) on Jun 07, 2012 at 23:15 UTC | |
by oldwarrior32 (Sexton) on Jun 08, 2012 at 13:53 UTC | |
by oldwarrior32 (Sexton) on Jun 07, 2012 at 16:12 UTC |