ID:               32139
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rtroll at yahoo-inc dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         SOAP related
 Operating System: *
 PHP Version:      5CVS-2005-02-28
-Assigned To:      
+Assigned To:      dmitry


Previous Comments:
------------------------------------------------------------------------

[2005-02-28 22:04:25] rtroll at yahoo-inc dot com

Changed summary.  For some reason, summary kept the same value as my
previously submitted bug.

------------------------------------------------------------------------

[2005-02-28 22:02:00] 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>


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32139&edit=1

Reply via email to