[system] / trunk / xmlrpc / RPC / RPC-XML-0.25 / methods / multicall.code Repository:
ViewVC logotype

View of /trunk/xmlrpc/RPC/RPC-XML-0.25/methods/multicall.code

Parent Directory Parent Directory | Revision Log Revision Log


Revision 279 - (download) (annotate)
Fri May 17 21:44:04 2002 UTC (17 years, 1 month ago) by gage
File size: 2000 byte(s)
Experimental xmlrpc WeBWorK webservices

    1 ###############################################################################
    2 #
    3 #   Sub Name:       multicall
    4 #
    5 #   Description:    Execute multiple method calls in a single request
    6 #
    7 #   Arguments:      NAME      IN/OUT  TYPE      DESCRIPTION
    8 #                   $srv      in      ref       Server object instance
    9 #                   $list     in      ref       List of struct's with the call
   10 #                                                 data within.
   11 #
   12 #   Globals:        None.
   13 #
   14 #   Environment:    None.
   15 #
   16 #   Returns:        Success:    listref
   17 #                   Failure:    fault object
   18 #
   19 ###############################################################################
   20 sub multicall
   21 {
   22     use strict;
   23 
   24     my $srv = shift;
   25     my $list = shift;
   26 
   27     my ($call, $subname, $params, $result, @results);
   28 
   29     my $name = $srv->{method_name};
   30 
   31     for $call (@$list)
   32     {
   33         unless (ref($call) eq 'HASH')
   34         {
   35             return RPC::XML::fault->new(200,
   36                                         "$name: One of the array elements " .
   37                                         'passed in was not a struct');
   38         }
   39 
   40         return RPC::XML::fault->new(310,
   41                                     "$name: Request was missing required " .
   42                                     '"methodName" member')
   43             unless ($subname = $call->{methodName});
   44         return RPC::XML::fault->new(310,
   45                                     "$name: Recursive calling of $name not " .
   46                                     'allowed')
   47             if ($subname eq $name);
   48 
   49         $params = $call->{params} || [];
   50         return RPC::XML::fault->new(200,
   51                                     "$name: Request's value for \"params\" " .
   52                                     'was not an array')
   53             unless (ref($params) eq 'ARRAY');
   54 
   55         $result = $srv->dispatch([ $subname, @$params ]);
   56         return $result if $result->is_fault;
   57 
   58         push @results, $result->value;
   59     }
   60 
   61     \@results;
   62 }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9