Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.14.0

Bug #4062 SOAPclient does not correctly decode BASE64 encoded values received
Submitted: 2005-04-05 13:34 UTC
From: incoming at pronet-romania dot com Assigned: chagenbu
Status: Closed Package: SOAP
PHP Version: 4.3.1 OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [2005-04-05 13:34 UTC] incoming at pronet-romania dot com
Description: ------------ I'm calling using soapclient a SOAP server that uses Perl. It returns (amongst other things) values that are base64 encoded (and sets the type="SOAP-ENC:base64" attribute on the corresponding XML tag). The type gets propagated to the $soapvalue->type property, however, it is never decoded, and $soap_client->_parse returns the base64 encoded value, in the corresponding structure. The problem is the fact that in this structure, there is no way of knowing if I should further process it and apply base64_encode on the value or not. Also, sorry, the SOAP service is only available in local network. Reproduce code: --------------- Here is the patch (sorry, text, being on windows, not too confortable with patch/diff tools): in SOAP/Base.php, in the method _decode (line 835), replace: return $soapval->value; with if ($soapval->type == 'base64') { return base64_decode($soapval->value); } else { return $soapval->value; } Expected result: ---------------- This should correct the problem, and decode the string when it is needed.

Comments

 [2005-04-06 15:38 UTC] incoming at pronet-romania dot com
Sorry, I spoke too soon, one more modification needed: Base.php, line 808: replace: if ($soapval->arrayType && $this->_isSoapValue($item)) { $item->type = $soapval->arrayType; } with: if ($soapval->arrayType && $this->_isSoapValue($item)) { if ($item->type == 'base64' && $soapval->arrayType != 'base64') { // must decode if we are losing the base64 information $item->value = base64_decode($item->value); } $item->type = $soapval->arrayType; }
 [2005-04-09 02:14 UTC] chagenbu
Please provide a small example (or a link to one) of a full XML response using base64 encoding. Then I'll implement and test the fix and add a unit test for it.
 [2005-04-10 19:41 UTC] incoming at pronet-romania dot com
Sorry, no file attachment permitted. Here is the result XML (search for "mission" to get to the base64 part) Let me know if you need more information, and thanks for your response. -------8<------- <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'> <SOAP-ENV:Body> <namesp1:WSgetProfilesResponse xmlns:namesp1='http://people.epfl.ch/PeopleWS'> <s-gensym3> <arrayOfPubItems SOAP-ENC:arrayType='xsd:anyType[1]' xsi:type='SOAP-ENC:Array'> <item> <urlpub xsi:type='xsd:string'> http://ditwww.epfl.ch/publications-spip/auteur.php3?id_auteur=236 </urlpub> <indexpub xsi:type='xsd:int'> 1508 </indexpub> <ordrepub xsi:type='xsd:int'> 0 </ordrepub> <revuepub xsi:type='xsd:string'/> <titrepub xsi:type='xsd:string'> Articles dans le Flash Informatique </titrepub> <auteurspub xsi:type='xsd:string'> I.Cionca </auteurspub> </item> </arrayOfPubItems> <encv> <creator xsi:type='xsd:int'> 104782 </creator> <lastmodby xsi:type='xsd:int'> 104782 </lastmodby> <sciper xsi:type='xsd:int'> 104782 </sciper> <datecr xsi:type='xsd:string'> 2004-08-31 18:56:59 </datecr> <cvlang xsi:type='xsd:string'> en </cvlang> <datemod xsi:type='xsd:string'> 2004-12-01 16:28:31 </datemod> </encv> <web_perso xsi:type='xsd:string'> http://kis.epfl.ch/page44412.html </web_perso> <frcv> <creator xsi:type='xsd:int'> 104782 </creator> <lastmodby xsi:type='xsd:int'> 104782 </lastmodby> <sciper xsi:type='xsd:int'> 104782 </sciper> <datecr xsi:type='xsd:string'> 2004-08-31 18:57:05 </datecr> <cvlang xsi:type='xsd:string'> fr </cvlang> <datemod xsi:type='xsd:string'> 2005-02-19 00:27:11 </datemod> <mission xsi:type='xsd:base64Binary'> UOhyZSBkZSBHQVNQQVIsIGRlcyBhcHBsaWNhdGlvbnMgZGUgZ2VzdGlvbiBkZXMgYWJzZW5jZXMgZXQgculzZXJ2YXRpb25zLCBjb21tYW5kZXMgZGUgY2FydGVzIGRlIHZ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NlIEluZm9ybWF0aXF1ZSBDZW50cmFsIGRlIGwnRVBGTA0KMTk5Ny0yMDA0IDogc3VwcG9ydCBhdSBk6XZlbG9wcGVtZW50IHdlYiBldCBiYXNlcyBkZSBkb25u6WVzLCBTZXJ2aWNlIEluZm9ybWF0aXF1ZSBDZW50cmFsIGRlIGwnRVBGTA0KMjAwNC0yMDA1IDogZOl2ZWxvcHBlbWVudCBkJ2FwcGxpY2F0aW9ucyB3ZWIsIGJhc2VzIGRlIGRvbm7pZXMsIHNlcnZpY2VzIGRpc3RyaWJ16WVzIGF1IEtJUw0K </curriculum> </frcv> <nbfunct xsi:type='xsd:int'> 2 </nbfunct> <phones xsi:type='xsd:string'> [+41 21 69] 34586 </phones> <rooms xsi:type='xsd:string'> MAC1652 </rooms> <mail xsi:type='xsd:string'> ion.cionca@epfl.ch </mail> <sciper xsi:type='xsd:int'> 104782 </sciper> <arrayOfBoxes SOAP-ENC:arrayType='xsd:anyType[1]' xsi:type='SOAP-ENC:Array'> <item> <boxcontent xsi:type='xsd:base64Binary'> PGltZyBzcmM9aHR0cDovL3NpaXBjMTcuZXBmbC5jaC9teXBob3Rvcy9pb25za2kvaS1jb2xvci5qcGcgYWxpZ249bGVmdCB2c3BhY2U9NXB4IHdpZHRoPTUwPjxpbWcgc3JjPWh0dHA6Ly93d3cuY3NzbS1tb3JnZXMuY2gvaW1ncy9jYXJ0ZTYuZ2lmIGFsaWduPWxlZnQgdnNwYWNlPTVweCBoc3BhY2U9NXB4IGhlaWdodD01MD4tIHBsb25n6WUgKGVudHJlIGF1dHJlcywgYXUgPGEgaHJlZj1odHRwOi8vd3d3LmNzc20tbW9yZ2VzLmNoLz48Yj5DU1NNIGRlIE1vcmdlczwvYj48L2E+OyA8YSBocmVmPWh0dHA6Ly9zaWlwYzE3LmVwZmwuY2gvd2ViZnVuL3Bsb25nZWUuaHRtPm1lcyBzb3J0aWVzIG3pbW9yYWJsZXM8L2E+KQ0KLSB2b2lsZSAoY2F0YW1hcmFuIDxhIGhyZWY9aHR0cDovL3NpaXBjMTcuZXBmbC5jaC9tYXR0aWEvRGVmYXVsdC5odG0+TWF0dGlhIDE4PC9hPikNCi0gcGhvdG8gbnVt6XJpcXVlIChQYW5hc29uaWMgRloyMCBldCBDYW5vbiBJeHVzIDMwKQ0KLSBtdXNpcXVlcyAoZGVzIHZpZWlsbGVyaWVzIGRlcyBhbm7pZXMgcG9wLXJvY2ssIGVuIHBhc3NhbnQgcGFyIGxlIGZ1bmNrIGRlIFByaW5jZSBldCBmaW5pciBhdmVjIGR1IGphenosIGhpcC1ob3Agb3UgcmFwOyBjbGFzc2lxdWUgYXVzc2kgYXBwculjaek7IGV0aG5vOiBpbmRlLXBha2lzdGFuLCBhcmFiZSwgYWZyaXF1ZSkNCi0gZmlsbXMgKGZhbiBkZSBkZSBOaXJvIGRhbnMgc2EgamV1bmVzc2UgU2NvcnNlc2UgZXQgU2VyZ2lvIExlb25lLCBUYXJrb3Zza2ksIEZvcm1hbiwgTW9udHkgUHl0aG9ucywgVGFyYW50aW5vLi4uIGV0IGonZW4gcGFzc2UpDQotIGRlc3NpbiwgcG90ZXJpZQ0KLSBsZXMgZ2FkZ2V0cyDpbGVjdHJvbmlxdWVz </boxcontent> <boxordre xsi:type='xsd:int'> 0 </boxordre> <boxpos xsi:type='xsd:string'> C </boxpos> <boxlang xsi:type='xsd:string'> fr </boxlang> <boxlabel xsi:type='xsd:string'> LOISIRS </boxlabel> </item> </arrayOfBoxes> <affects SOAP-ENC:arrayType='xsd:string[2]' xsi:type='SOAP-ENC:Array'> <item xsi:type='xsd:string'> DIT-DEV,EPFL PL PL-DIT DIT-DEV,Informaticien-ne,1 </item> <item xsi:type='xsd:string'> KIS,EPFL PL PL-DIT KIS,Informaticien-ne,2 </item> </affects> <prenom xsi:type='xsd:string'> Ion </prenom> <photourl xsi:type='xsd:string'> http://infowww.epfl.ch/photos/SCIPERpublic.Photo </photourl> <nom xsi:type='xsd:string'> Cionca </nom> </s-gensym3> </namesp1:WSgetProfilesResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
 [2005-05-03 17:01 UTC] chagenbu
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. ... or at least, it will be fixed in CVS once the CVS server is enabled again. Thanks for the test case.