For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Puli's avatar
Puli
Icon for Nimbostratus rankNimbostratus
Mar 20, 2008

How 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's avatar
    Puli
    Icon for Nimbostratus rankNimbostratus
    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