Nick Lo-2 wrote:
>
>
> On the issue note I was also wondering whether the issue I pointed
> out with the Word characters could be seen as a Zend_XmlRpc_Server
> issue or merely a note about filtering out the data properly. Either
> way it would be less of an issue if it was possible to define types
> as you are mentioning.
>
>
I've dug a little deeper into this problem using the current ZF svn trunk
(rev 6613), and wanted to post some additional (and more accurate) results:
/**
* 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><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></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 problem that
Nik has found, I think). The datetime value is correct, tho. From looking at
the code, it appears that wrapping values in specific Zend_XmlRpc_Value
classes like above is how we "should" be doing doing things, but there
appear to be bugs in how the value classes convert the data when sending
responses via the server and upon receiving with the client...
In my initial post in this thread, I said that my datetime was being
returned as an int - This was incorrect. After retesting, the server is
returning the data type definitions correctly, but 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><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></params></methodResponse>
...which shows:
* The datetime value is wrapped as a string.
* The base65 value has been "correctly" decoded, and is wrapped as a string
(the server had encoded the value improperly).
So, for my datetime problem, it is up to me to convert the dateTime.iso8601
string to a unix timestamp at the client. And, for Nik's Base65 problem, he
must manually encode his values, pass them as strings, and then decode them
at the client:
/**
* 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']);
}
I'm unsure yet if the Zend_XmlRpc_Value_DateTime should be converting to the
unix timestamp in its getValue() method, or if the
Zend_XmlRpc_Value_Base64::getValue() is incorrect in decoding the stored
value. There is a bug reported in regards to the Base64 value, I'll add my
findings to this issue.
http://framework.zend.com/issues/browse/ZF-1799 ZF-1799 Issue:
Zend_XmlRpc_Value_Base64 is saved to XML request in decoded form
Cheers!
--
View this message in context:
http://www.nabble.com/XML-RPC-Server-and-defining-return-types-within-an-array-of-struct-tf4591398s16154.html#a13143537
Sent from the Zend Framework mailing list archive at Nabble.com.