Forum Discussion
Michel_van_der_
Jun 04, 2003Nimbostratus
Another SOAP::Lite newbie question
How would I go about translating some predefined constants,
such as ITCMLocalLB.LBMethod ?
Looking through the wsdl file, it would appear this is only defined
with documentation, not in ...
Jun 04, 2003
There are several ways to go about this. We've used both of them in the SDK sample code.
In sdk/support/SOAP/LocalLB/LocalLBPool.pl we used a hash map to convert values to names
my $LBMethodMap =
{
0 => "Round Robin",
1 => "Ratio",
2 => "Fastest",
3 => "Least Connections",
4 => "Ratio Member",
5 => "Least Connections Member",
6 => "Observed Member",
7 => "Predictive Member",
8 => "Observed Node Address",
9 => "Predictive Node Address",
10 => "Dynamic Ratio",
};
And reference it in the code as like list
----------------------------------------------------------------------------
Get the load balancing method for the given pool
----------------------------------------------------------------------------
sub getPoolLBMethod()
{
my ($poolName) = @_;
my $lbMethod;
my $soap_response =
$soap->get_lb_method
(
SOAP::Data->name ( pool_name => $poolName )
);
if ( $soap_response->fault )
{
print $soap_response->faultcode, "\n";
print $soap_response->faultstring, "\n";
exit("");
}
else
{
$lbMethod = $soap_response->result;
}
return $LBMethodMap->{$lbMethod};
}
You could also create global variables and reference them accordingly.
my $LB_METHOD_ROUND_ROBIN = 0;
my $LB_METHOD_RATIO = 1;
my $LB_METHOD_FASTEST = 2;
my $LB_METHOD_LEAST_CONN = 3;
my $LB_METHOD_RATIO_MEMBER = 4;
my $LB_METHOD_LEAST_CONN_MEMBER = 5;
my $LB_METHOD_OBSERVED_MEMBER = 6;
my $LB_METHOD_PREDICTIVE_MEMBER = 7;
my $LB_METHOD_OBSERVED_NODE_ADDR = 8;
my $LB_METHOD_PREDICTIVE_NODE_ADDR = 9;
my $LB_METHOD_DYNAMIC_RATIO = 10;
my $soap_response =
soap->set_lb_method
(
SOAP::Data->name ( pool_name => $poolName ),
SOAP::Data->name ( lb_method => $LB_METHOD_ROUND_ROBIN)
);
-Joe
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