Re: byte[] to PHP-string conversion RESOLVED
"Gaetano Giunta" <[email protected]> Fri, 18 Jul 2008 10:22:20 +0200
| Newsgroups | gmane.comp.php.xml-rpc |
|---|---|
| Message-ID | <[email protected]> |
--===============0993264804== Content-Type: multipart/alternative; boundary="----=_Part_50390_11169557.1216369340870" ------=_Part_50390_11169557.1216369340870 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Fri, Jul 18, 2008 at 10:14 AM, Marcel Ruff <[email protected]> wrote: > 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. > > > Thanks > Marcel > > > Gaetano Giunta wrote: > >> Marcel Ruff a =E9crit : >> >>> 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 >> extension is much faster, but the library is more complete. >> >> Bye >> Gaetano >> >>> >>> regards >>> Marcel >>> >>> >>> Marcel Ruff wrote: >>> >>>> 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><qos/></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 =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> >>>> // 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 >>>> >>>> >>>> _______________________________________________ >>>> phpxmlrpc mailing list >>>> [email protected] >>>> http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc >>>> >>>> >>> _______________________________________________ >>> phpxmlrpc mailing list >>> [email protected] >>> 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 > [email protected] > http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc > ------=_Part_50390_11169557.1216369340870 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline <div dir=3D"ltr"><br><br><div class=3D"gmail_quote">On Fri, Jul 18, 2008 at= 10:14 AM, Marcel Ruff <<a href=3D"mailto:[email protected]">mr@marcelr= uff.info</a>> wrote:<br><blockquote class=3D"gmail_quote" style=3D"borde= r-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-le= ft: 1ex;"> Thanks for the details.<br> <br> What do you mean by 'xmlrpc extension' versus 'phpxmlrpc librar= y'?<br> Isn't everything phpxmlrpc? Are there two implementations in parallel?<= /blockquote><div><br>there are actually more than two.<br><br>Just to name = the more common ones:<br>phpxmlrpc - the first one<br>pear xmllrpc - a fork= of this one<br> zend xmlrpc - another one<br>incutio xmlrpc - yet another one<br>(all of th= e above are coded in php, so they can be used in many environments)<br><br>= php xmlrpc extension - is a php extension, so it is coded in C, has been bu= ndled in php iirc since version 4.3 or 4.4.<br> <br></div><blockquote class=3D"gmail_quote" style=3D"border-left: 1px= solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><= br> <br> Thanks<br> Marcel<div><div></div><div class=3D"Wj3C7c"><br> <br> Gaetano Giunta wrote:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Marcel Ruff a =E9crit :<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi again,<br> <br> changing the code to<br> <br> $res =3D php_xmlrpc_decod= e( $result->value() );<br> <br> // instead of<br> // $res =3D xmlrpc_decode( $result->serialize() );<br> <br> resolved it (i have not investigated further to understand it),<br> </blockquote> The function xmlrpc_decode is from the php xmlrpc extension<br> The function php_xmlrpc_decode is from the phpxmlrpc library<br> <br> 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 ex= tension is much faster, but the library is more complete.<br> <br> Bye<br> Gaetano<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <br> regards<br> Marcel<br> <br> <br> Marcel Ruff wrote:<br> <blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, = 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi,<br> <br> i have a Java xmlrpc server which returns an array of triples<br> {<br> String key<br> byte[] content<br> String qos<br> }<br> <br> When i call it with phpxmlrpc i get:<br> <br> <methodResponse><br> <params><br> <param><br> <value><br> <array><br> <data><br> <value><br> <array><br> <data><br> <value><s= tring>Hello</string></value><br> <value><b= ase64>MzQz</base64></value><br> <value><s= tring>&lt;qos/&gt;</string></value><br> </data><br> </array><br> </value><br> </data><br> </array><br> </value><br> </param><br> </params><br> </methodResponse><br> <br> Now my problem:<br> <br> I can read in PHP the two strings without problem<br> but how can i read the binary data (encoded with base64)?<br> <br> $result =3D $this->client->send( $rpcmsg );<br> $res_array =3D xmlrpc_decode( $result->serialize() );<br> $messages =3D array( count($res_array) ) ;<br> $cpt =3D 0 ;<br> foreach( $res_array as $r ){<br> dbgprint( "OK: [$r[0]]" );<br> // $r[1] from <value><base64>MTg4Mw=3D=3D</base64>= </value><br> // THIS FAILS:<br> dbgprint( "binary data: $r[1]" );<br> }<br> <br> Error thrown:<br> ----> Object of class stdClass could not be converted to string in ...<b= r> <br> But $r[1] should contain the text "Hi".<br> <br> What am i missing?<br> <br> Thanks<br> Marcel<br> <br> <br> _______________________________________________<br> phpxmlrpc mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">phpxmlrp= [email protected]</a><br> <a href=3D"http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc" t= arget=3D"_blank">http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxml= rpc</a><br> <br> </blockquote> <br> _______________________________________________<br> phpxmlrpc mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">phpxmlrp= [email protected]</a><br> <a href=3D"http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc" t= arget=3D"_blank">http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxml= rpc</a><br> <br> </blockquote> <br> <br> </blockquote> <br> <br></div></div><font color=3D"#888888"> -- <br> Marcel Ruff<br> <a href=3D"http://www.xmlBlaster.org" target=3D"_blank">http://www.xmlBlast= er.org</a><br> <a href=3D"http://watchee.net" target=3D"_blank">http://watchee.net</a><br> Phone: +49 7551 309371</font><div><div></div><div class=3D"Wj3C7c"><br> <br> _______________________________________________<br> phpxmlrpc mailing list<br> <a href=3D"mailto:[email protected]" target=3D"_blank">phpxmlrp= [email protected]</a><br> <a href=3D"http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc" t= arget=3D"_blank">http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxml= rpc</a><br> </div></div></blockquote></div><br></div> ------=_Part_50390_11169557.1216369340870-- --===============0993264804== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ phpxmlrpc mailing list [email protected] http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc --===============0993264804==--