server022.phpt 1.2 KB

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