#native_company# #native_desc#

The web of services: using XML_RPC Page 9

By Luis Argerich
on March 29, 2001

An xmlrpcval object may be created using this forms:


$myVal=new xmlrpcval($stringVal);

$myVal=new xmlrpcval($scalarVal"int" "boolean" "string" "double" "dateTime.iso8601" "base64");

$myVal=new xmlrpcval($arrayVal"array" "struct");


The first creates a xmlrpc string value, the second creates a scalar value indicating value and type, the
third one may be used to create complex objects by grouping other xmlrpc vals in structures such as arrays
or structures as following:


$myArray=new xmlrpcval(array(

xmlrpcval("Tom"), new xmlrpcval("Dick"),

xmlrpcval("Harry")), "array");

          $myStruct=new xmlrpcval(array(

"name" => new xmlrpcval("Tom"),

"age" => new xmlrpcval(34"int"),

"geek" => new xmlrpcval(1"boolean")), "struct");


The response object is of type xmlrpcresp and is obtained calling the method “send” from a client object,
in a server you can create an xmlrpc resp using:
$resp=new xmlrpcresp($xmlrpcval);
In the client you use the method:
To get the xmlrpcval from the response. Then you can use this method to get a PHP variable representing the response:
There’re two useful functions to deal with complex types:
These functions reside in xmlrpc.inc.
Returns a PHP array stuffed with the values found in the xmlrpcval $xmlrpc_val, translated into native PHP types.
Returns an xmlrpcval populated with the PHP values in $phpval. Works recursively on arrays and structs. Note that there’s no support for non-base types like base-64 values or date-times.
Writing clients is a easy task in PHP, you can build web-based clients for XML_RPC services using PHP.