PHP :: Bug #47273 :: Encoding bug in SoapServer->fault
| Bug #47273 | Encoding bug in SoapServer->fault | ||||
|---|---|---|---|---|---|
| Submitted: | 2009-02-02 10:16 UTC | Modified: | 2009-08-26 14:06 UTC | ||
| From: | shaselboeck at m-s dot de | Assigned: | dmitry (profile) | ||
| Status: | Closed | Package: | SOAP related | ||
| PHP Version: | 5.2.8 | OS: | Windows | ||
| Private report: | No | CVE-ID: | None | ||
[2009-02-02 10:16 UTC] shaselboeck at m-s dot de
Description:
------------
Setting up an SoapServer with another encoding as UTF-8 - for example Cp1252 - SoapServer->fault() will not correct encode the message.
By throwing a SoapFault with an message, the encoding will be done correctly, but SoapServer->fault() does not.
To suppress error, I run an internal encoding.
mb_convert_encoding($string, 'UTF-8', $this->getEncoding());
Reproduce code:
---------------
All code listed here is part of a complex class hierarchy in combination with the Zend Framework.
--------------------------------------------
SERVER-CODE
----------------------- ---------------------
$server = new SoapServer('http://xxx.de/?wsdl', array('encoding' => 'Cp1252'));
$server->setClass('SoapFaultTest');
try {
$server->handle();
}
catch (Exception $e) {
$this->fault('Sender', $e->getMessage());
}
--------------------------------------------
CLIENT-CODE
--------------------------------------------
try {
$client = new SoapClient('http://xxx.de/?wsdl', array('encoding' => 'Cp1252'));
echo $client->test();
}
catch (SoapFault $fault) {
echo 'Error: ' . $fault->getMessage();
}
--------------------------------------------
SERVICE-CLASS SoapFaultTest
--------------------------------------------
class SoapFaultTest
{
public function test() {
throw new Exception('Exception with some special chars: ???');
}
}
Expected result:
----------------
Exception with some special chars: ???
Actual result:
--------------
SOAP-ERROR: Encoding: string 'Exception with some special chars: \xc4...' is not a valid utf-8 string
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-02-18 14:23 UTC] dmitry@php.net
[2009-03-10 14:13 UTC] shaselboeck at m-s dot de
[2009-08-26 14:06 UTC] dmitry@php.net