Forum Discussion
Paul_Lavoie_724
Nimbostratus
Dec 27, 2006Trouble with PoolMember->get_session_enabled_state in perl
Hi!
I'm starting to write perl scripts using the iControl API to replace some bigpipe shell scripts, and seem to have run into a problem.
The following application:
!/usr/bin/perl -w
use SOAP::Lite;
use MIME::Base64;
Variables for
our $sUID = 'user';
our $sPWD = 'password';
our $sProtocol = 'https';
our $sPort = 443;
initSOAPtoLB('devbigip1');
sub initSOAPtoLB ($) {
my ($sHost) = shift; Name of load balancer...
my $Pool = SOAP::Lite->uri('urn:iControl:LocalLB/Pool')
->proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi");
eval { $Pool->transport->http_request->header(
'Authorization' => 'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
); };
my $PoolMember = SOAP::Lite->uri('urn:iControl:LocalLB/PoolMember')
->proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi");
eval { $PoolMember->transport->http_request->header(
'Authorization' => 'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
); };
my $resp = $Pool->get_list;
checkResponse($resp);
my @poolList = @{$resp->result};
my @sess = undef;
foreach my $p (@poolList) {
print "$p\n";
my $resp2 = $PoolMember->get_session_enabled_state
(
SOAP::Data->name(pool_names => [$p])
);
eval {
checkResponse($resp2);
push(@sess, @{$resp2->result});
};
}
foreach my $s (@sess) {
print "$s\n";
}
return ($Pool, $PoolMember, \@poolList);
}
does not seem to handle the get_session_enabled_state method properly. The error output from the script is:
news_thin
Unrecognized type '{urn:iControl}Common.EnabledState'
xmlns:E="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:A="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://www.w3.org/2001/XMLSchema-instance"
xmlns:y="http://www.w3.org/2001/XMLSchema"
xmlns:iControl="urn:iControl"
E:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
xmlns:m="urn:iControl:LocalLB/PoolMember">
s:type="A:Array"
A:arrayType="iControl:LocalLB.PoolMember.MemberSessionState[][1]">
A:arrayType="iControl:LocalLB.PoolMember.MemberSessionState[1]">
s:type="iControl:LocalLB.PoolMember.MemberSessionState">
s:type="iControl:Common.IPPortDefinition">
s:type="y:string">10.72.170.75
s:type="y:long">10428
s:type="iControl:Common.EnabledState">STATE_ENABLED
at ./testiCtrl.pl line 136
which to me looks like a definition error within iControl. Any suggestions?
- The Common.EnabledState type is one of our enum values. You'll need to include the iControlTypeCast.pm file located in the sdkroot\sdk\samples\soap\perl\soaplite directory. The file contains all of our custom types with the mapping logic. Take a look at the SDK samples for info on how to include it.
- The only thing I can think of is that you put some print statements in the iControlTypeCast.pm file in the subroutine to find out the type that is passed in and whether it's getting pulled from the hash correctly. Could be that the deserialize subroutine isn't getting called.
- Paul_Lavoie_724
Nimbostratus
Well, your suggestion got me to a point that I got it to work. The redefinition of the serialize command which was plucked from one of the sample scripts was to blame. The version in the header file does need some cleanup in order to work with the perl '-w' flag, however. I suggest:
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects