ZF-5704: SoapServer->fault() will not correct encode the exception-message

Issue Type: Improvement Created: 2009-02-06T00:30:44.000+0000 Last Updated: 2009-09-09T11:11:34.000+0000 Status: Resolved Fix version(s): Reporter: Sven (sunnysven) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_Soap_Server

Related issues: Attachments:


Setting up an SoapServer with another encoding as UTF-8 - for example ISO-8859-1 - 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 this php error (I reported that bug to, 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.


<pre class="highlight">
$server = new Zend_Soap_Server('<a href=""></a>', array('encoding' => 'ISO-8859-1'));


<pre class="highlight">
try {
    $client = new SoapClient('<a href=""></a>', array('encoding' => 'ISO-8859-1'));
    echo $client->test();
catch (SoapFault $fault) {
    echo 'error: ' . $fault->getMessage();


<pre class="highlight">
class SoapFaultTest
    public function test() {
        throw new Exception('Exception with some special chars: Äßö');

IMPROVEMENT FOR Zend_Soap_Server on line 941 (SVN)

<pre class="highlight">
return new SoapFault($code, $this->_convertEncoding($message));

 * Converts non UTF-8 characters to UTF-8 charachters.
 * That is essential, otherwise PHPs Soap Extension will throw a SoapFault
 * SOAP-ERROR: Encoding: string '...' is not a valid utf-8 string
 * @param string String to encode
 * @return string correct Encoded String
protected function _convertEncoding($string) {
    return 0 === strlen($this->getEncoding() || 'utf-8' === strtolower($this->getEncoding())) ? $string : mb_convert_encoding($string, 'UTF-8', $this->getEncoding());

So by throwing exceptions the exception-message will be converted correctly and the php bug can be circumvented.


Posted by Benjamin Eberlei (beberlei) on 2009-02-06T01:43:54.000+0000

thanks for the report, i'll look into it.

the problem, why i can't use your solution is the mbstring extension, which is not allowed in ZF components without a fallback. But iconv should be doing roughly good too :-)

Posted by Benjamin Eberlei (beberlei) on 2009-02-06T06:25:02.000+0000

I do wait for this bug to be confirmed on (link:, then i will implement a workaround.

Posted by Benjamin Eberlei (beberlei) on 2009-09-09T11:11:34.000+0000

The underlying PHP bug has been fixed, so this is marked as non-issue.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.