I've run into this issue as well using the main trunk (rev 6613)...
/**
* GetNames
*
* @return array
*/
function GetNames()
{
$ret = array(
array(
'id'=>1,
'name'=>'Jack',
'created_dt'=>new Zend_XmlRpc_Value_DateTime(1191877812),
'encoded'=>new Zend_XmlRpc_Value_Base64('testing 1..2..3')
)
);
return $ret;
}
$server->addFunction("GetNames");
$response = $server->handle();
...The raw xml response from the server when calling this function is:
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse><params><param><value><array><data><value><struct>
<member><name>id</name><value><int>1</int></value></member>
<member><name>name</name><value><string>Jack</string></value></member>
<member><name>created_dt</name><value><dateTime.iso8601>20071008T14:10:12</dateTime.iso8601></value></member>
<member><name>encoded</name><value><base64>testing 1..2..3</base64></value></member>
</struct></value></data></array></value></param></params></methodResponse>
...which shows that the server is correctly wrapping the data values for the datetime and base64, but the base64 value is not encoded. The datetime value is correct.
The Zend_XmlRpc_Client is handling the response differently which confused me a little:
(from $xmlrpcClient->getLastResponse())
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse><params><param><value><array><data><value><struct>
<member><name>id</name><value><int>1</int></value></member>
<member><name>name</name><value><string>Jack</string></value></member>
<member><name>created_dt</name><value><string>20071008T14:10:12</string></value></member>
<member><name>encoded</name><value><string>µëŠx5</string></value></member>
</struct></value></data></array></value></param></params></methodResponse>
...which shows:
- The datetime value is wrapped as a string.
- The base65 value has been decoded, and is wrapped as a string (the server had encoded the value "improperly"
).
Is the desired behavior of Zend_XmlRpc_Client to support automatic conversion of these datatypes, or is it up to the user to convert?
Potential workaround is below, but is undesirable long term.
/**
* GetNames
*
* @return array
*/
function GetNames()
{
$ret = array(
array(
'id'=>1,
'name'=>'Jack',
'created_dt'=>new Zend_XmlRpc_Value_DateTime(1191877812),
'encoded'=>base64_encode('testing 1..2..3')
)
);
return $ret;
}
... and then on the client...
$retval = $client->call('GetNames');
for ($i=0; $i<count($retval); $i++) {
$retval[$i]['created_dt'] = strtotime($retval[$i]['created_dt']);
$retval[$i]['encoded'] = base64_decode($retval[$i]['encoded']);
}
Assigned to Matthew