Hi,
we are currently moving from php4 (4.4.0) to php5 (5.0.5) and we bump into a problem concerning xmlrpc_decode. The problem is that the output of xmlrpc_decode is somehow corrupt. Look at the sample code below:
$xml='<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><struct><member><name>123</name><value><string>456</string></value></member><member><name>hi</name><value><string>there</string></value></member></struct></value></param></params></methodResponse>';
$retval = xmlrpc_decode($xml);
print 'var_export whole $retval<br>';
var_export($retval);
while (list($key, $value) = each($retval))
{
print '<br><br>Found key '.$key.'<br>';
$keyExists = array_key_exists($key, $retval);
print 'array_key_exists: ';
var_export($keyExists);
print '<br><br>var_export $retval['.$key.']<br>';
var_export($retval[$key]);
}
The result of this on php 4.4.0 is
var_export whole $retval: array ( 123 => '456', 'hi' => 'there', )
Found key: 123
array_key_exists: true
var_export $retval[123]: '456'
Found key: hi
array_key_exists: true
var_export $retval[hi]: 'there'
On the other hand, with php 5.0.5 the output is
var_export whole $retval: array ( '123' => '456', 'hi' => 'there', )
Found key: 123
array_key_exists: false
var_export $retval[123]: NULL
Found key: hi
array_key_exists: true
var_export $retval[hi]: 'there'
The difference is that with php 5.0.5 the output from xmlrpc_decode is slightly different, array key 123 is within single quotes and as you can see, the key is found in the array but cannot be accessed.
Since xmlrpc_decode is experimental, this cannot be a marked as a bug (or can it?). Can anybody help me in getting a workaround for this?
Any help will be highly appreciated.
Richard
Edit: As a workaround the whole array can be copied into a new one (by using recursive foreach). If somebody has another workaround, please let me know.XML-RPC is in some cases different between PHP 4 and PHP 5 , the main different is in the way you parse the XML Requests and Response , also there is a different in the installation of the packages (Installation Settings) . You can read more about Webservices in PHP4 and PHP5 from here
<!-- m --><a class="postlink" href="http://www.smartvi.com/webservices.htm">http://www.smartvi.com/webservices.htm</a><!-- m -->
Regards ,
we are currently moving from php4 (4.4.0) to php5 (5.0.5) and we bump into a problem concerning xmlrpc_decode. The problem is that the output of xmlrpc_decode is somehow corrupt. Look at the sample code below:
$xml='<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><struct><member><name>123</name><value><string>456</string></value></member><member><name>hi</name><value><string>there</string></value></member></struct></value></param></params></methodResponse>';
$retval = xmlrpc_decode($xml);
print 'var_export whole $retval<br>';
var_export($retval);
while (list($key, $value) = each($retval))
{
print '<br><br>Found key '.$key.'<br>';
$keyExists = array_key_exists($key, $retval);
print 'array_key_exists: ';
var_export($keyExists);
print '<br><br>var_export $retval['.$key.']<br>';
var_export($retval[$key]);
}
The result of this on php 4.4.0 is
var_export whole $retval: array ( 123 => '456', 'hi' => 'there', )
Found key: 123
array_key_exists: true
var_export $retval[123]: '456'
Found key: hi
array_key_exists: true
var_export $retval[hi]: 'there'
On the other hand, with php 5.0.5 the output is
var_export whole $retval: array ( '123' => '456', 'hi' => 'there', )
Found key: 123
array_key_exists: false
var_export $retval[123]: NULL
Found key: hi
array_key_exists: true
var_export $retval[hi]: 'there'
The difference is that with php 5.0.5 the output from xmlrpc_decode is slightly different, array key 123 is within single quotes and as you can see, the key is found in the array but cannot be accessed.
Since xmlrpc_decode is experimental, this cannot be a marked as a bug (or can it?). Can anybody help me in getting a workaround for this?
Any help will be highly appreciated.
Richard
Edit: As a workaround the whole array can be copied into a new one (by using recursive foreach). If somebody has another workaround, please let me know.XML-RPC is in some cases different between PHP 4 and PHP 5 , the main different is in the way you parse the XML Requests and Response , also there is a different in the installation of the packages (Installation Settings) . You can read more about Webservices in PHP4 and PHP5 from here
<!-- m --><a class="postlink" href="http://www.smartvi.com/webservices.htm">http://www.smartvi.com/webservices.htm</a><!-- m -->
Regards ,