php.net |  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
Votes:7
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: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rtroll at yahoo-inc dot com
New email:
PHP Version: OS:

 

 [2005-02-28 22:02 UTC] rtroll at yahoo-inc dot com
Description:
------------
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:
---------------
<?php

$WSDL = "http://ws1.api.re2.yahoo.com/ws/soap-demo/full.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:

<SOAP-ENV:Body>
<ns1:echoViaBase64>
<ns1:src>1234567890abcdefghijklmnopqrstuvwxyz</ns1:src>
</ns1:echoViaBase64>
</SOAP-ENV:Body>


Actual result:
--------------
The request should look something like this:

<SOAP-ENV:Body>
<ns1:echoViaBase64>
<ns1:src>MTIzNDU2Nzg5MGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6</ns1:src>
</ns1:echoViaBase64>
</SOAP-ENV:Body>

Patches

Pull Requests

History

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] iliaa@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC