Forum Discussion
Hamish_Marson_3
Nimbostratus
Oct 13, 2005SOAP::Lite 'dies' when 401 auth required...
Hi.
I've got my code almost working. Except for some boundary conditions. One of which is when the username/password isn't correct in the SOAP request.
For auth, I'm specifying the username & password in the ->proxy() parameter with the proxy URL. e.g.
$ITCMSystemInfo = SOAP::Lite
-> uri('urn:iControl:ITCMSystem/SystemInfo')
-> proxy("$sProtocol://$icUser:$icPass\@$icServer:$icPort/iControl/iControlPortal.cgi");
This works fine until either the $icUser or $icPass are incorrect. At which time the call
$soapResponse = $ITCMSystemInfo->get_product_info();
dies in execution. With
401 Authorization Required at /usr/local/src/bigip.control/icon/walkF5Config line 1131
Nice... It's correct, there was an auth error, but what I'd really like is for the routine to return, and for my code to pickup the 401 error and continue on to make the problem in a database. At the moment all I get is my app exiting.
How can I over-ride the dieing successfully (not being a SOAP expert, this is my first SOAP::Lite application).
I've tried over-riding the on_fault() call when creating $ITCMSystemInfo, e.g.
but although my routine gets called, if IT doesn't call die() then the app runs & bombs out with the following error (AFTER the call to setDeviceError has been invoked BTW, so the call itself works).
on_fault() expects subroutine (CODE) or string that evaluates into subroutine (CODE) at /usr/local/src/bigip.control/icon/walkF5Config line 1116
$ITCMSystemInfo = SOAP::Lite
-> uri('urn:iControl:ITCMSystem/SystemInfo')
-> proxy("$sProtocol://$icUser:$icPass\@$icServer:$icPort/iControl/iControlPortal.cgi")
-> on_fault(setDeviceError($dbh, 'getBIGIPVersion', $devID));
[Line 1116 being the '$ITCMSystemInfo = SOAP::Lite' above.
Surrounding all the calls with eval's & testing $@ does work, but it's ugly... e.g.
if(eval {
$ITCMSystemInfo = SOAP::Lite
-> uri('urn:iControl:ITCMSystem/SystemInfo')
-> proxy("$sProtocol://$icUser:$icPass\@$icServer:$icPort/iControl/iControlPortal.cgi");
}) {
print "getBIGIPVersion: A fault occured trying to communicate with the F5 device SOAP::Lite\n";
return "Unknown";
}
print "getBIGIPVersion: ITCMSystemInfo is $ITCMSystemInfo\n";
print Dumper($ITCMSystemInfo);
if(eval {
$soapResponse = $ITCMSystemInfo->get_product_info();
}) {
print "getBIGIPVersion: A fault occured trying to communicate with the F5 device get_product_info()\n";
return "Unknown";
}
Does anyone have a better way?
TIA
Hamish.
- I believe the "eval" route is your best option. The HTTP transport layer is outside of the SOAP::Lite code and don't believe there are traps in there to catch those errors from the underlying transport library.
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