RE: [phpxmlrpc] I'm Lost with phpxmlrpc

2006-02-03 Thread Gaetano Giunta



Uhm, I 
might be getting it wrong, but it looks like you took the code I proposed 
as used it as-is (almost) in your application.
It was 
actually meant as an example.
 
More 
specifically, If I read it correctly, your XMLRPC looks like 
this:
 
ARRAY 
=> {
  
STRUCT => {
    ITINERARIO_CODIGO => XXX
  
}
}
 
To 
access the 'itinerario codigo' data, you need to use not arraymem($i), but rather stuctmem('ITINERARIO_CODIGO')  on line 60, since 
$sig will be an xmlrpcval of type 'struct' at that point.
 
I see 
you are also trying to access 2 members of the struct (member 0 and 
member 1) on line 59 and line 60, but you only have one.
 
here's 
da code:
 
...
$numvals = $v->arraysize();
for ($i = 0; $i < $numvals; $i++)
{
  $innerval = $v->arraymem($i); // fecth element i of 
array
  $itinerary_code = $innerval->structmem('ITINERARIO_CODIGO'); // 
retrieve member out of struct element

  $itinerary_code = $itinerary_code->scalarval(); // get php 
string out of element
}
 
etc...

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of Overpeer 
  ---Sent: Friday, February 03, 2006 1:09 PMTo: 
  phpxmlrpc@lists.usefulinc.comSubject: [phpxmlrpc] I'm Lost with 
  phpxmlrpcHello, i probed it but:$signum = 
  $v->arraysize();        
      for($i = 0; $i < $signum; $i++)    
             {    
           print 
  $i;            
           $sig = 
  $v->arraymem($i);        
       $paramsnums = 
  $sig->arraysize()-1;        
       $retval = 
  $sig->arraymem(0);        
       $retval = 
  $sig->arraymem(1);        
      
     
              
              
   print 
  $retval->scalarval();    
  // Error here - Line 62        
       for ($j = 1; $j <= $paramsnums; 
  $j++)               
      {     
               $param = 
  $sig->arraymem($j);     
               echo "  
  Param number $j must be of type:".$param->scalarval()."\n";   
                  
  }              
              
           
      }            
      The error is: Fatal error: Call to a member 
  function on a non-object in /var/www/localhost/htdocs/client.php on 
  line 62The xml-rpc incoming is:    
       
        
      
    
  ITINERARIO_CODIGO  
  311    
    
    
      
    
  ITINERARIO_CODIGO  
  310    
      
     
     
  Some idea??? :S 
  :SA lot of thanks 
___
phpxmlrpc mailing list
phpxmlrpc@lists.usefulinc.com
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc


RE: [phpxmlrpc] I'm Lost with phpxmlrpc

2006-02-03 Thread Gaetano Giunta



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: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of Overpeer 
  ---Sent: Friday, February 03, 2006 10:32 AMTo: 
  phpxmlrpc@lists.usefulinc.comSubject: [phpxmlrpc] I'm Lost with 
  phpxmlrpcHello 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:ITI311
ITI310
ITI312
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 ;)
___
phpxmlrpc mailing list
phpxmlrpc@lists.usefulinc.com
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc