bug47273.phpt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Bug #47273 (Encoding bug in SoapServer->fault)
  3. --EXTENSIONS--
  4. soap
  5. --FILE--
  6. <?php
  7. $request1 = <<<EOF
  8. <?xml version="1.0" encoding="UTF-8"?>
  9. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://127.0.0.1:8080/test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test1/></SOAP-ENV:Body></SOAP-ENV:Envelope>
  10. EOF;
  11. $request2 = <<<EOF
  12. <?xml version="1.0" encoding="UTF-8"?>
  13. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://127.0.0.1:8080/test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test2/></SOAP-ENV:Body></SOAP-ENV:Envelope>
  14. EOF;
  15. class SoapFaultTest
  16. {
  17. public function test1() {
  18. // Test #1
  19. return 'Test #1 exception with some special chars: Äßö';
  20. }
  21. public function test2() {
  22. // Test #2
  23. //throw new SoapFault('Server', 'Test #2 exception with some special chars: Äßö');
  24. throw new Exception('Test #2 exception with some special chars: Äßö');
  25. }
  26. }
  27. $server = new SoapServer(null, array(
  28. 'uri' => "http://127.0.0.1:8080/test/",
  29. 'encoding' => 'ISO-8859-1'));
  30. $server->setClass('SoapFaultTest');
  31. try {
  32. $server->handle($request1);
  33. } catch (Exception $e) {
  34. $server->fault("Sender", $e->getMessage());
  35. }
  36. try {
  37. $server->handle($request2);
  38. } catch (Exception $e) {
  39. $server->fault("Sender", $e->getMessage());
  40. }
  41. ?>
  42. --EXPECT--
  43. <?xml version="1.0" encoding="UTF-8"?>
  44. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://127.0.0.1:8080/test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test1Response><return xsi:type="xsd:string">Test #1 exception with some special chars: Äßö</return></ns1:test1Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
  45. <?xml version="1.0" encoding="UTF-8"?>
  46. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</faultcode><faultstring>Test #2 exception with some special chars: Äßö</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>