Switch to using smart_encode, cos we are smart. Add support for <fault> in XML-RPC output to handle errors.

This commit is contained in:
ian%hixie.ch 2002-09-06 10:37:17 +00:00
Родитель daa424708a
Коммит 6e7c01e16e
1 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -93,6 +93,14 @@ sub getOutputHook {
return $self;
}
# output.hook
sub reportFatalError {
my $self = shift;
my($error) = @_;
my $response = RPC::XML::response->new(RPC::XML::fault->new(0, $error));
$self->output->XMLRPC($response->as_string);
}
# output.hook
sub methodMissing {
my $self = shift;
@ -104,15 +112,7 @@ sub methodMissing {
# have been designed so that there is enough information in the
# arguments to be useful.
my $response;
foreach my $argument (@arguments) {
if (ref($argument) eq 'ARRAY') {
$argument = RPC::XML::array->new(@$argument);
} elsif (ref($argument) eq 'HASH') {
$argument = RPC::XML::struct->new(%$argument);
} else {
$argument = RPC::XML::string->new($argument);
}
}
@arguments = RPC::XML::smart_encode(@arguments);
if (@arguments > 1) {
$response = RPC::XML::response->new(RPC::XML::array->new(@arguments));
} elsif (@arguments) {