Off the top of my head, there are two ways to achieve this:

1 - instead of having an unbounded list of parameters, just use an array as
second parameter, and put the strings inside the array.

Note that in this case the lib will only check that the 2nd param received
is an array, it will not check that the array members are strings, which
might pose a bit of a problem if the api is public (but if a controlled app
is the only client, then your code will mostly be fine without adding
further type checking)

Note 2: you can even have multiple sigs for a single method, this way:

$getObjectById_sig = array( array( $xmlrpcStruct, $xmlrpcInt, $xmlrpcString
), array( $xmlrpcStruct, $xmlrpcInt, $xmlrpcArray ) );
$getObjectById_doc = 'Returns the Object for a given ObjectID and
itemType(s).';
function getObjectById($m)
{
   global $xmlrpcerruser;
   $err = "";
   $n = php_xmlrpc_decode($m);
   $objectID     = $n[0];
   $objectTypes = $n[1];
   if (is_string($objectTypes))
      $objectTypes = array($objectTypes);
   foreach ($objectTypes as $obj)
      // ...

2 - if you remove the method signature from the php array that is fed to the
server object, the lib will not do any check at all on the input parameters
received, but feed directly the request obj tho your php method. This is
closer to a true varargs implementation, but then you should check in code
that you at least got two parameters, the fiurst one being int and all the
others being string (again, if the only caller app is under your control you
might skip those checks)

Bye
Gaetano

On 8/8/07, Matthias Korn <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> i have just a quick question on how to access a variable number of
> parameters in my php client app.
> The current (w/o variable number of parameters) signature and parameter
> access looks like this:
>
> //-------------------------
> $getObjectById_sig = array( array( $xmlrpcStruct, $xmlrpcInt,
> $xmlrpcString ) );
> $getObjectById_doc = 'Returns the Object for a given ObjectID and
> itemType.';
> function getObjectById($m)
> {
>     global $xmlrpcerruser;
>     $err = "";
>     $n = php_xmlrpc_decode($m);
>     $objectID     = $n[0];
>     $objectType = $n[1];
>     // ...
> //-------------------------
>
> But now the last param $xmlrpcString (later in $objectType) becomes an
> unknown number of params of the same type (string). The method call I
> get looks like this, where the last parameters is an unknown amount
> (here: three).
>
> //-------------------------
> <?xml version=" 1.0"?>
> <methodCall>
>   <methodName>getObjectById</methodName>
>   <params>
>     <param>
>       <value>
>         <i4>216205</i4>
>       </value>
>     </param>
>     <param>
>       <value>
>         <string>ToDo_ToDo</string>
>       </value>
>     </param>
>     <param>
>       <value>
>         <string>ToDo_Support</string>
>       </value>
>     </param>
>     <param>
>       <value>
>         <string>ToDo_Contact</string>
>       </value>
>     </param>
>   </params>
> </methodCall>
> //-------------------------
>
> How do I have to modify signature and parameter access to achieve a
> variable number of parameters?
>
> Thanks a lot,
> Matthias Korn
> _______________________________________________
> phpxmlrpc mailing list
> phpxmlrpc@lists.usefulinc.com
> http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
>
_______________________________________________
phpxmlrpc mailing list
phpxmlrpc@lists.usefulinc.com
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc

Reply via email to