bug38005.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Bug #38005 (SoapFault faultstring doesn't follow encoding rules)
  3. --EXTENSIONS--
  4. soap
  5. --INI--
  6. soap.wsdl_cache_enabled=0
  7. --FILE--
  8. <?php
  9. function Test($param=NULL) {
  10. return new SoapFault('Test', 'This is our fault: Ä');
  11. }
  12. class TestSoapClient extends SoapClient {
  13. function __construct($wsdl, $opt) {
  14. parent::__construct($wsdl, $opt);
  15. $this->server = new SoapServer($wsdl, $opt);
  16. $this->server->addFunction('Test');
  17. }
  18. function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
  19. ob_start();
  20. $this->server->handle($request);
  21. $response = ob_get_contents();
  22. ob_end_clean();
  23. return $response;
  24. }
  25. }
  26. $client = new TestSoapClient(NULL, array(
  27. 'encoding' => 'ISO-8859-1',
  28. 'uri' => "test://",
  29. 'location' => "test://",
  30. 'soap_version'=>SOAP_1_2,
  31. 'trace'=>1,
  32. 'exceptions'=>0));
  33. $res = $client->Test();
  34. echo($res->faultstring."\n");
  35. echo($client->__getLastResponse());
  36. ?>
  37. --EXPECT--
  38. This is our fault: Ä
  39. <?xml version="1.0" encoding="UTF-8"?>
  40. <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>Test</env:Value></env:Code><env:Reason><env:Text>This is our fault: Ä</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>