Discussion:
[phpxmlrpc] byte[] to PHP-string conversion
Marcel Ruff
2008-07-17 21:00:22 UTC
Permalink
Hi,

i have a Java xmlrpc server which returns an array of triples
{
String key
byte[] content
String qos
}

When i call it with phpxmlrpc i get: <methodResponse> <params> <param> <value> <array> <data> <value> <array> <data> <value><string>Hello</string></value> <value><base64>MzQz</base64></value> <value><string>&lt;qos/&gt;</string></value>
</data>
</array>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>

Now my problem:

I can read in PHP the two strings without problem
but how can i read the binary data (encoded with base64)?

$result = $this->client->send( $rpcmsg );
$res_array = xmlrpc_decode( $result->serialize() );
$messages = array( count($res_array) ) ;
$cpt = 0 ;
foreach( $res_array as $r ){
dbgprint( "OK: [$r[0]]" );
// $r[1] from <value><base64>MTg4Mw==</base64></value>
// THIS FAILS:
dbgprint( "binary data: $r[1]" );
}

Error thrown:
----> Object of class stdClass could not be converted to string in ...

But $r[1] should contain the text "Hi".

What am i missing?

Thanks
Marcel
Marcel Ruff
2008-07-17 23:12:12 UTC
Permalink
Hi again,

changing the code to

$res = php_xmlrpc_decode( $result->value() );

// instead of
// $res = xmlrpc_decode( $result->serialize() );

resolved it (i have not investigated further to understand it),

regards
Marcel
Post by Marcel Ruff
Hi,
i have a Java xmlrpc server which returns an array of triples
{
String key
byte[] content
String qos
}
</data>
</array>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
I can read in PHP the two strings without problem
but how can i read the binary data (encoded with base64)?
$result = $this->client->send( $rpcmsg );
$res_array = xmlrpc_decode( $result->serialize() );
$messages = array( count($res_array) ) ;
$cpt = 0 ;
foreach( $res_array as $r ){
dbgprint( "OK: [$r[0]]" );
// $r[1] from <value><base64>MTg4Mw==</base64></value>
dbgprint( "binary data: $r[1]" );
}
----> Object of class stdClass could not be converted to string in ...
But $r[1] should contain the text "Hi".
What am i missing?
Thanks
Marcel
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
Gaetano Giunta
2008-07-18 04:08:58 UTC
Permalink
Post by Marcel Ruff
Hi again,
changing the code to
$res = php_xmlrpc_decode( $result->value() );
// instead of
// $res = xmlrpc_decode( $result->serialize() );
resolved it (i have not investigated further to understand it),
The function xmlrpc_decode is from the php xmlrpc extension
The function php_xmlrpc_decode is from the phpxmlrpc library

Both server the same purpose, ie creating xmlrpc servers and clients in
php, but they should generally not be mixed up. As a general guideline,
the extension is much faster, but the library is more complete.

Bye
Gaetano
Post by Marcel Ruff
regards
Marcel
Post by Marcel Ruff
Hi,
i have a Java xmlrpc server which returns an array of triples
{
String key
byte[] content
String qos
}
</data>
</array>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
I can read in PHP the two strings without problem
but how can i read the binary data (encoded with base64)?
$result = $this->client->send( $rpcmsg );
$res_array = xmlrpc_decode( $result->serialize() );
$messages = array( count($res_array) ) ;
$cpt = 0 ;
foreach( $res_array as $r ){
dbgprint( "OK: [$r[0]]" );
// $r[1] from <value><base64>MTg4Mw==</base64></value>
dbgprint( "binary data: $r[1]" );
}
----> Object of class stdClass could not be converted to string in ...
But $r[1] should contain the text "Hi".
What am i missing?
Thanks
Marcel
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
Marcel Ruff
2008-07-18 14:14:25 UTC
Permalink
Thanks for the details.

What do you mean by 'xmlrpc extension' versus 'phpxmlrpc library'?
Isn't everything phpxmlrpc? Are there two implementations in parallel?

Thanks
Marcel
Post by Gaetano Giunta
Post by Marcel Ruff
Hi again,
changing the code to
$res = php_xmlrpc_decode( $result->value() );
// instead of
// $res = xmlrpc_decode( $result->serialize() );
resolved it (i have not investigated further to understand it),
The function xmlrpc_decode is from the php xmlrpc extension
The function php_xmlrpc_decode is from the phpxmlrpc library
Both server the same purpose, ie creating xmlrpc servers and clients
in php, but they should generally not be mixed up. As a general
guideline, the extension is much faster, but the library is more
complete.
Bye
Gaetano
Post by Marcel Ruff
regards
Marcel
Post by Marcel Ruff
Hi,
i have a Java xmlrpc server which returns an array of triples
{
String key
byte[] content
String qos
}
</data>
</array>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
I can read in PHP the two strings without problem
but how can i read the binary data (encoded with base64)?
$result = $this->client->send( $rpcmsg );
$res_array = xmlrpc_decode( $result->serialize() );
$messages = array( count($res_array) ) ;
$cpt = 0 ;
foreach( $res_array as $r ){
dbgprint( "OK: [$r[0]]" );
// $r[1] from <value><base64>MTg4Mw==</base64></value>
dbgprint( "binary data: $r[1]" );
}
----> Object of class stdClass could not be converted to string in ...
But $r[1] should contain the text "Hi".
What am i missing?
Thanks
Marcel
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
--
Marcel Ruff
http://www.xmlBlaster.org
http://watchee.net
Phone: +49 7551 309371
Gaetano Giunta
2008-07-18 14:22:24 UTC
Permalink
Post by Marcel Ruff
Thanks for the details.
What do you mean by 'xmlrpc extension' versus 'phpxmlrpc library'?
Isn't everything phpxmlrpc? Are there two implementations in parallel?
there are actually more than two.

Just to name the more common ones:
phpxmlrpc - the first one
pear xmllrpc - a fork of this one
zend xmlrpc - another one
incutio xmlrpc - yet another one
(all of the above are coded in php, so they can be used in many
environments)

php xmlrpc extension - is a php extension, so it is coded in C, has been
bundled in php iirc since version 4.3 or 4.4.
Post by Marcel Ruff
Thanks
Marcel
Post by Gaetano Giunta
Post by Marcel Ruff
Hi again,
changing the code to
$res =3D php_xmlrpc_decode( $result->value() );
// instead of
// $res =3D xmlrpc_decode( $result->serialize() );
resolved it (i have not investigated further to understand it),
The function xmlrpc_decode is from the php xmlrpc extension
The function php_xmlrpc_decode is from the phpxmlrpc library
Both server the same purpose, ie creating xmlrpc servers and clients in
php, but they should generally not be mixed up. As a general guideline, =
the
Post by Marcel Ruff
Post by Gaetano Giunta
extension is much faster, but the library is more complete.
Bye
Gaetano
Post by Marcel Ruff
regards
Marcel
Post by Marcel Ruff
Hi,
i have a Java xmlrpc server which returns an array of triples
{
String key
byte[] content
String qos
}
</data>
</array>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
I can read in PHP the two strings without problem
but how can i read the binary data (encoded with base64)?
$result =3D $this->client->send( $rpcmsg );
$res_array =3D xmlrpc_decode( $result->serialize() );
$messages =3D array( count($res_array) ) ;
$cpt =3D 0 ;
foreach( $res_array as $r ){
dbgprint( "OK: [$r[0]]" );
// $r[1] from <value><base64>MTg4Mw=3D=3D</base64></value>
dbgprint( "binary data: $r[1]" );
}
----> Object of class stdClass could not be converted to string in ...
But $r[1] should contain the text "Hi".
What am i missing?
Thanks
Marcel
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
--
Marcel Ruff
http://www.xmlBlaster.org
http://watchee.net
Phone: +49 7551 309371
_______________________________________________
phpxmlrpc mailing list
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.usefulinc.com/pipermail/phpxmlrpc/attachments/20080718/b7=
f16060/attachment.htm

Loading...