30-May-2003
14:59
- last edited on
22-Nov-2022
16:35
by
JimmyPackets
secondary_error_code and error_string), but, not being much of a SOAP expert, I can't see
where the error gets encapsulated. E.g. the examples code shows:
if ( $soap_response->fault ) {
print $soap_response->faultcode, "(faultstring) ", $soap_response->faultstring, "\n";
print $soap_response->faultcode, "(faultdetail) ", $soap_response->faultdetail, "\n";
}
Which will give something like this:
SOAP-ENV:Server(faultstring) ITCMCommon::OperationFailed Exception caught on ITCMLocalLB::Monitor::get_node_monitor().
primary_error_code : 132
secondary_error_code: 0
error_string : Monitor template not found
SOAP-ENV:Server(faultdetail)
I don't know how to get this back as some sort of perl structure.
Anyone here now?
30-May-2003 14:59
BTW, With the upcoming SOAP v1.2 faults, more detail will be able to be included in the soapfault elements!
-Joe
30-May-2003
14:59
- last edited on
22-Nov-2022
16:35
by
JimmyPackets
Calling code
...
if ( $soapResponse->fault )
{
&printFault($soapResponse->faultcode, $soapResponse->faultstring);
}
----------------------------------------------------------------------------
Print out a soap fault
----------------------------------------------------------------------------
sub printFault()
{
my ($faultCode, $faultString) = @_;
my ($primary, $secondary, $str) = &getFaultDetails($faultString);
print "Fault Code: $faultCode\n";
print "Fault Details:\n";
print " Primary Error Code: $primary\n";
print " Secondary Error Code: $secondary\n";
print " Error String: $str\n";
}
----------------------------------------------------------------------------
Extract the primary error code, secondary error code,
and error string
----------------------------------------------------------------------------
sub getFaultDetails()
{
my ($faultString) = @_;
my $primary_error_code;
my $secondary_error_code;
my $error_string;
Split details into lines
@lines = split("\n", $faultString);
foreach $line (@lines)
{
split line into name : value pairs and trim strings
@parts = split(":", $line);
$name = &trimString(@parts[0]);
$value = &trimString(@parts[1]);
set values depending on detail element names.
if ( "$name" eq "primary_error_code" )
{
$primary_error_code = $value;
}
elsif ( "$name" eq "secondary_error_code" )
{
$secondary_error_code = $value;
}
elsif ( $name eq "error_string" )
{
$error_string = $value;
}
}
return ($primary_error_code, $secondary_error_code, $error_string);
}
----------------------------------------------------------------------------
Helper to trim leading and tailing whitespace from a string
----------------------------------------------------------------------------
sub trimString()
{
my ($str) = @_;
$str =~ s/^ |\t|\n//;
$str =~ s/\s*$//;
return $str;
}
You should be able to adapt this to suit your needs.
-Joe
30-May-2003 14:59
already doing exactly what you suggested.
I've made more progress in the last 1.5 days than I did for 2 weeks when I first started
to look at iControl 2.1.
Can't say enough times how useful this forum is for me.