[phpxmlrpc] return an array

Didier M.J.C. Gehéniau didier.geheniau at feas.net
Fri Dec 5 13:11:00 CET 2008



That was one problem and de second one i found out: my array was “lastname”,
“geheniau” and not “lastname => “geheniau” ;)


It’s working now




On Fri, Dec 5, 2008 at 12:27 AM, <didier.geheniau at feas.net> wrote:

Hi all,

I have the following simple code:

include ("lib/xmlrpc.inc");
include ("lib/xmlrpcs.inc");
include ("lib/xmlrpc_wrappers.inc");

$userInfo = new xmlrpcval ( array(
               "dgeheniau", new xmlrpcval (
                               "lastname", new xmlrpcval ("Geheniau",
                               "firstname", new xmlrpcval ("Didier",
                               "email", new xmlrpcval ("email at address.com",
       ), "struct");

$getUserInfo_sig = array(array($xmlrpcStruct, $xmlrpcString));
$getUserInfo_doc = "This function will return all know user info!";

function getUserInfo ($userName){

Here $userName will not be a string but an object.
You will need to extract the 1st param received from this object, and its
then its string value.
Btw, if you are doing all the encoding/decoding from php values to xmlrpc
values by hand you do not need to include xmlrpc_wrappers.inc - that lib is
used when you want to automatically turn plain php functions (ie functions
that do not deal with xmlrpcvals) into server methods.


       global $userInfo;
       return new xmlrpcresp(new
xmlrpcval($userInfo->structmem("$userName"), "struct"));


#$o=new xmlrpc_server_methods_container;
       "user.getUserInfo" => array(
               "function" => "getUserInfo",
               "signature" => $getUserInfo_sig,
               "docstring" => $getUserInfo_doc

$s=new xmlrpc_server($a, false);
$s->compress_response = true;

In the client I get:

Object of class xmlrpcmsg could not be converted to string
Undefined index:

What am I doing wrong?




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.usefulinc.com/pipermail/phpxmlrpc/attachments/20081205/8eb19983/attachment.htm 

More information about the phpxmlrpc mailing list