ID:               47273
 User updated by:  shaselboeck at m-s dot de
 Reported By:      shaselboeck at m-s dot de
-Status:           No Feedback
+Status:           Open
 Bug Type:         SOAP related
-Operating System: Linux
+Operating System: Windows
 PHP Version:      5.2.8
 Assigned To:      dmitry
 New Comment:

I set up a new test with XAMPP Lite 1.7.0 (Apache 2.2.11 + PHP 5.2.8).
The following 3 files are located in: http://localhost/soap/

Here my soap-server (index.php)
------------------------------------------------------------
<?php
require('SoapFaultTest.php');

$server = new SoapServer(null, array('uri' => 'http://localhost/soap/',
'encoding' => 'ISO-8859-1'));
$server->setClass('SoapFaultTest');

try {
        $server->handle();
} catch (Exception $e) {
        $server->fault("Sender", $e->getMessage());
}
?>


My service class (SoapFaultTest.php)
------------------------------------------------------------
<?php
class SoapFaultTest
{
    public function test() {
        //  Test #1
        return 'Test #1 exception with some special chars: Äßö';
        
        //  Test #2
        //throw new Exception('Test #2 exception with some special
chars: Äßö');
    }
}
?>


And my soap-client (client.php)
------------------------------------------------------------
<?php
try {
    $client = new SoapClient(null, array(
                'location'      => 'http://127.0.0.1/soap/index.php',
                'uri'           => 'http://127.0.0.1/soap/',            
                'encoding'      => 'ISO-8859-1')
        );    
    echo $client->test();
}
catch (SoapFault $fault) {
    echo 'Error: ' . $fault->getMessage();
}
?>


Getting test-results by http://localhost/soap/client.php:

Test #1 - result as expected:
Test #1 exception with some special chars: Äßö

Test #2 - result:
Error: SOAP-ERROR: Encoding: string 'Test #2 exception with some
special chars: \xc4...' is not a valid utf-8 string

Test #2 - expected:
Test #2 exception with some special chars: Äßö

SoapServer->fault() ignores the encoding!
Hope you can now reproduce the bug.


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

[2009-02-26 01:00:02] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

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

[2009-02-18 14:23:29] dmi...@php.net

I cannot reproduce it.

Do you have the bag only with faults?
Doesn't it occur if you just return string with special characters?

May be the bug is related to ext/mbstring. Try to set
mbstring.http_input and mbstring.http_output to "pass".

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

[2009-02-02 10:16:38] 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


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


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

Reply via email to