[phpxmlrpc] I'm Lost with phpxmlrpc

Gaetano Giunta giunta.gaetano at sea-aeroportimilano.it
Fri Feb 3 10:10:39 GMT 2006


The doc and examples are quite clear (in my humble opinion) indicating that:

- the client->send() method returns an xmlrpcresp object

- the resp->value() method returns an xmlrpcval object (of course you should check for the error code first, to see if there was a communication error)

- xmlrpcval objects have some methods that can be used depending on their type. For structs and arrays, in particular:

  + for xmlrpcval of type array: val->arraysize(), val->arraymem()
  + for xmlrpcval of type struct:  val->structsize(), val->structmem(), val->structeach(), val->structreset(), val->structmemexixts(),

- there is also a second method to access the data of an xmlrpcval object, decoding it all-at-once into plain php values: $php_values = php_xmlrpc_decode($xmlrpcval);

here's a code snippet to get you running:

 $f = new xmlrpcmsg('system.methodSignature', array(new xmlrpcval(system.methodHelp));
 $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
 $r = $c->send($f);
 if(!$r->faultCode())
 {
  $v = php_xmlrpc_decode($r->value());
  var_dump($v); // this will echo a standard php array. You can access it as you prefer

  $v = $r->value();
  $signum = $v->arraysize();
  for($i = 0; $i < $signum; $i++)
  {
   $sig = $v->arraymem($i);
   $paramsnums = $sig->arraysize()-1;
   $retval = $sig->arraymem(0);
   echo "Found a signature\n  Return type is: ".$retval->scalarval()."\n";
   for ($j = 1; $j <= $paramsnums; $j++)
   {
     $param = $sig->arraymem($j);
     echo "  Param number $j must be of type: ".$param->scalarval()."\n";
   }
  }

 }

PS: I think you might have a problem due to the linguistic barrier: what is your native language? I can answer in italian or french if you prefer...

Hope it helps
Gaetano

  -----Original Message-----
  From: phpxmlrpc-bounces at lists.usefulinc.com [mailto:phpxmlrpc-bounces at lists.usefulinc.com]On Behalf Of Overpeer ---
  Sent: Friday, February 03, 2006 10:32 AM
  To: phpxmlrpc at lists.usefulinc.com
  Subject: [phpxmlrpc] I'm Lost with phpxmlrpc


  Hello all in my first message to the list.

  I'm trying implement a simple webservice with xml-rpc, I´m make the client with phpxmlrpc on Apache2 on GNU/Linux.

  The servers, is makes in Delphi and works OK, it send mi things like this:

<methodResponse><params><param><value><array><data><value><struct><member><name>ITI</name><value><string>311</string></value>
</member></struct></value><value><struct><member><name>ITI</name><value><string>310</string></value></member></struct></value>
<value><struct><member><name>ITI</name><value><string>312</string></value></member></struct></value></data></array></value>
</param></params></methodResponse>Whats could be the logic structure to access the structures and arrays for procesing the data?? I has read the documentation but i can't find examples with clients and structures, and de commads explain don't be clear for me :|

  A lot of thanks ;)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.gnomehack.com/pipermail/phpxmlrpc/attachments/20060203/4e205ae7/attachment.htm


More information about the phpxmlrpc mailing list