Forum Discussion
Puli
Nimbostratus
Mar 20, 2008How to capture return messages in perl
Am trying to capture return messages in a perl variable so i can make decisions based on that.
Specificatlly am want capture return message from
$soapResponse = $PoolMember->get_session_enabled_state
(
SOAP::Data->name(pool_names => [@pool_list])
);
Can anyone help.
Ven
4 Replies
- Do a site search on "PoolMember->get_session_enabled_state" and you'll see a bunch of perl samples using that method. Here's one from the CodeShare:
http://devcentral.f5.com/wiki/default.aspx/iControl/TogglePoolMember.html
Click here
-Joe - Puli
Nimbostratus
sorry, more information.
what am trying to do is capture the error message when username password is wrong.
When i execute with wrong username/password. The code exits with below message
401 F5 Authorization Required at checkLogin.pl line 414
anyway i can capture this meessage into a variable so i can create a if then else to display user friendly message. - An example of that is in that sample on code share as well. Look at the checkResponse() subroutine. You can see if the fault member of the $soapResponse is set, and if so, get the value form the $soapResponse->faultcode and $soapResponse->faultstring.
-Joe - Ok, I think I get what you are getting at. If you want to trap HTTP level error messages, you'll need to put an eval around your call and then interrogate the $soap->transport class's members (code, message, & status)
eval { $soapResponse = $PoolMember->get_session_enabled_state ( SOAP::Data->name(pool_names => [@pool_list]) ); }; if ( $PoolMember->transport->status != 200 ) { print "Code : ", $PoolMember->transport->code, "\n"; print "Message: ", $PoolMember->transport->message, "\n"; print "Status : ", $PoolMember->transport->status, "\n"; exit; } else { ... }
Hopefully this get's you going.
-Joe
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
