server018.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. SOAP Server 18: user fault (through throw)
  3. --EXTENSIONS--
  4. soap
  5. --FILE--
  6. <?php
  7. function test() {
  8. throw new SoapFault("MyFault","My fault string");
  9. }
  10. $server = new soapserver(null,array('uri'=>"http://testuri.org"));
  11. $server->addfunction("test");
  12. $HTTP_RAW_POST_DATA = <<<EOF
  13. <?xml version="1.0" encoding="ISO-8859-1"?>
  14. <SOAP-ENV:Envelope
  15. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  16. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  17. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  18. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19. xmlns:si="http://soapinterop.org/xsd">
  20. <SOAP-ENV:Body>
  21. <ns1:test xmlns:ns1="http://testuri.org"/>
  22. </SOAP-ENV:Body>
  23. </SOAP-ENV:Envelope>
  24. EOF;
  25. $server->handle($HTTP_RAW_POST_DATA);
  26. echo "ok\n";
  27. ?>
  28. --EXPECT--
  29. <?xml version="1.0" encoding="UTF-8"?>
  30. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>MyFault</faultcode><faultstring>My fault string</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
  31. ok