|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32139 base64binary encode/decode
Submitted: 2005-02-28 22:02 UTC Modified: 2005-07-27 16:52 UTC
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:6 (85.7%)
From: rtroll at yahoo-inc dot com Assigned:
Status: Closed Package: SOAP related
PHP Version: 5CVS-2005-02-28 OS: *
Private report: No CVE-ID:
 [2005-02-28 22:02 UTC] rtroll at yahoo-inc dot com
When building a SOAP client or server that uses the "base64Binary" XML datatype, PHP is not performing the appropriate B64 encoding/decoding.

When generating a SOAP client based on a WSDL, the PHP SOAP extension builds a collection of methods for me.  These methods take args (as defined by the WSDL), and send them over the wire to the appropriate service.  The extension takes care of encoding arrays as arrays, decimals as decimals, etc.  If the item datatype is "base64Binary", the extension does not b64 encode the value - it merely places it in the XML.

This may be a feature, requiring client authors to read through the WSDL to determine what datatypes are being used, in order to adequately encode things before passing them into the autogenerated methods.  If this is the appropriate functionality, the "time_t -> dateTime" mapping should also be removed, providing a consistent, "PHP does no data munging" approach to generated interfaces.

However, I'd much rather see the extension do the B64 encoding for me. :)

Consider a service that returns an image: getImage().  It could be implemented such that the image is transmitted in b64 - but the client author shouldn't need to know that.

Reproduce code:

$WSDL = "";
$SRCBUF = "1234567890abcdefghijklmnopqrstuvwxyz";

$client = new SoapClient( $WSDL, array( "trace" => true,
                                        "exceptions" => 0,
function dump_xml( $title, $body )
    $nl = preg_replace( "/\>\</", ">\n<", $body );
    $clean = htmlspecialchars( $nl );
    print "\n<b>$title</b>\n<pre>$clean</pre>\n";

$r = $client->echoViaBase64( array( 'src' => $SRCBUF ));
dump_xml( "Request", $client->__getLastRequest() );
dump_xml( "Response", $client->__getLastResponse() );

Expected result:
The request generated by this PHP5 SOAP client contains the following body:


Actual result:
The request should look something like this:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-28 22:04 UTC] rtroll at yahoo-inc dot com
Changed summary.  For some reason, summary kept the same value as my previously submitted bug.
 [2005-03-28 17:57 UTC] forvia at yandex dot ru
SoapClient do not decode response which in base64Binary format...
 [2005-07-27 16:52 UTC]
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Tue Dec 01 12:01:36 2015 UTC