|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28969 Wrong data encoding of special characters
Submitted: 2004-06-30 09:38 UTC Modified: 2004-08-11 08:25 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: ba at esoft dot dk Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5.0.0RC3 OS: Linux 2.6.7-gentoo-r3
Private report: No CVE-ID: None
 [2004-06-30 09:38 UTC] ba at esoft dot dk
I'm using SOAP webservices and need to send special characters (danish letters in my case) in the data, it seems these letters break the SOAP parser.

Previously we have used NuSOAP for webservices, and here special letters are encoded / decoded transparantly.

Reproduce code:
class testWebservice {
	function test() {
		return "???";

$SOAP = new SoapServer("test.wsdl");

Expected result:
The returned string "???"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-10 18:37 UTC]
Fixed in CVS HEAD.

By default ext/soap espect all string data in utf-8 encoding.

Now it is possible to change internal encoding with "encoding" option. It is acceptable both by SoapClient and SoapServer.

$SOAP = new SoapServer("test.wsdl", 

 [2004-08-11 08:25 UTC] ba at esoft dot dk
I will check it out.. sounds great!
 [2004-08-13 08:52 UTC] bryanguo at 21cn dot com
Hi, I tested the "encoding" option, but it doesn't work yet. In my case, I need to send/receive chinese characters in the data. So firstly I hope the SOAP data can encode with "gb2312":
$SOAP = new SoapServer("test.wsdl",array('encoding'=>'gb2312'));

Unfortunately, the return data is like below and "encoding" option is still 'UTF-8':
HTTP/1.1 200 OK
Date: Fri, 13 Aug 2004 06:42:12 GMT
Server: Apache/2.0.48 (Unix) PHP/5.0.0
X-Powered-By: PHP/5.0.0
Set-Cookie: SCP_WS_SESSIONID=635131d75dc3b040f0d96e88518fe02c; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 639
Connection: close
Content-Type: text/xml; charset="utf-8"

<?xml version="1.0" encoding="UTF-8"?>
   <SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="http://xxx" xmlns:ns2="http://xxx" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC="" SOAP-ENV:encodingStyle="">
            <FindDriversReturn SOAP-ENC:arrayType="ns2:Driver[0]" xsi:type="ns1:ArrayOf_tns1_Driver"/>

What's the problem?
 [2004-08-15 21:28 UTC] cdcampos at netcabo dot pt
I've checked with the current version (5.0.1) and it's working fine both in SoapClient and SoapServer.

The problem that remains is with SoapFault. It seems it's not recognizing the enconding given before to the Server or Client Class. Here is an example:

function AlteraEstado($dados) {
	if ($dados == 'GARBAGE') return new SoapFault("Server", "?edilha");
	else return array("Answer"=>"OK");
$server = new SoapServer("GPR.wsdl", array('encoding'=>'ISO-8859-1'));

This code returns no valid XML Soap Envelope back to client (I suppose it breaks...).
 [2004-08-17 09:40 UTC] hailei at starsoftcomm dot com
        function FindZipInfo($zipCode)
                /*if($zipCode == 100021)
                        $str = "Beijing";
                        $str = "????";
                return $str;*/
                return $zipCode;

        $server = new SoapServer("", array('encoding'=>'GB2312'));
                $client = new SoapClient("", array('encoding'=>'GB2312', 'trace' => 1));
                $result = $client->FindZipInfo("&Ouml;&ETH;&Icirc;&Auml;&frac14;??&Ntilde;??&frac14;??&Ntilde;??&frac14;??&Ntilde;??test&frac14;??&Ntilde;??&raquo;??&cedil;&iuml;&acute;&icirc;&Aacute;??");
                //echo $client->__getLastRequest();
                echo $client->__getLastResponse();
                //echo $result;
        catch(SoapFault $fault)
                echo "SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})";
<?xml version="1.0" encoding="UTF-8" ?> 
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="" xmlns:xsd="" xmlns:xsi="" xmlns:SOAP-ENC="" SOAP-ENV:encodingStyle="">
- <SOAP-ENV:Body>
- <ns1:FindZipInfoResponse>
  <CITY xsi:type="xsd:string">???ΔΌ???????????test????????????</CITY> 
~my question: why:
<?xml version="1.0" encoding="UTF-8" ?>
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jun 01 14:01:27 2020 UTC