server028.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. SOAP Server 28: SoapServer::setObject and __call()
  3. --EXTENSIONS--
  4. soap
  5. --FILE--
  6. <?php
  7. class Foo {
  8. function __call($name, $args) {
  9. if ($name == "test") {
  10. return "Hello World";
  11. } else {
  12. return SoapFault("Server","Function $name doesn't exist");
  13. }
  14. }
  15. }
  16. $foo = new Foo();
  17. $server = new SoapServer(null,array('uri'=>"http://testuri.org"));
  18. $server->setObject($foo);
  19. $HTTP_RAW_POST_DATA = <<<EOF
  20. <?xml version="1.0" encoding="ISO-8859-1"?>
  21. <SOAP-ENV:Envelope
  22. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  23. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  24. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  25. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  26. xmlns:si="http://soapinterop.org/xsd">
  27. <SOAP-ENV:Body>
  28. <ns1:test xmlns:ns1="http://testuri.org" />
  29. </SOAP-ENV:Body>
  30. </SOAP-ENV:Envelope>
  31. EOF;
  32. $server->handle($HTTP_RAW_POST_DATA);
  33. echo "ok\n";
  34. ?>
  35. --EXPECT--
  36. <?xml version="1.0" encoding="UTF-8"?>
  37. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" 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:testResponse><return xsi:type="xsd:string">Hello World</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
  38. ok